Skip to content

Commit

Permalink
Bindings and API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 13, 2016
1 parent 46606b2 commit 39f7c04
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 22 deletions.
14 changes: 14 additions & 0 deletions python/core/qgseditformconfig.sip
Expand Up @@ -179,6 +179,20 @@ class QgsAttributeEditorContainer : QgsAttributeEditorElement
*/
void setColumnCount( int columnCount );

/**
* An expression that controls the visibility of this container.
*
* @note Added in QGIS 2.18
*/
QgsOptionalExpression visibilityExpression() const;

/**
* An expression that controls the visibility of this container.
*
* @note Added in QGIS 2.18
*/
void setVisibilityExpression( const QgsOptionalExpression& visibilityExpression );

};

/**
Expand Down
19 changes: 19 additions & 0 deletions python/gui/qgsfieldexpressionwidget.sip
Expand Up @@ -53,6 +53,17 @@ class QgsFieldExpressionWidget : QWidget
*/
QString asExpression() const;

/**
* Returns the currently selected field or expression. If a field is currently selected, the returned
* value will be converted to a valid expression referencing this field (ie enclosing the field name with
* appropriate quotations).
*
* Alias for asExpression()
*
* @note added in QGIS 2.18
*/
QString expression() const;

//! Returns the currently used layer
QgsVectorLayer* layer() const;

Expand Down Expand Up @@ -90,6 +101,14 @@ class QgsFieldExpressionWidget : QWidget
//! sets the current field or expression in the widget
void setField( const QString &fieldName );

/**
* Sets the current expression text and if applicable also the field.
* Alias for setField.
*
* @note Added in QGIS 2.18
*/
void setExpression( const QString& expression );

protected slots:
//! open the expression dialog to edit the current or add a new expression
void editExpression();
Expand Down
27 changes: 21 additions & 6 deletions python/gui/qgstabwidget.sip
Expand Up @@ -18,7 +18,7 @@
* The QgsTabWidget class is the same as the QTabWidget but with additional methods to
* temporarily hide/show tabs.
*
* @note Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
class QgsTabWidget : QTabWidget
{
Expand All @@ -30,28 +30,28 @@ class QgsTabWidget : QTabWidget
/**
* Create a new QgsTabWidget with the optionally provided parent.
*
* @note Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
QgsTabWidget( QWidget *parent = nullptr );

/**
* Hides the tab with the given widget
*
* @note Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
void hideTab( QWidget* tab );

/**
* Shows the tab with the given widget
*
* @note Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
void showTab( QWidget* tab );

/**
* Control the visibility for the tab with the given widget.
*
* @note Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
void setTabVisible( QWidget* tab, bool visible );

Expand All @@ -60,10 +60,25 @@ class QgsTabWidget : QTabWidget
* This index is not the same as the one provided to insertTab and removeTab
* since these methods are not aware of hidden tabs.
*
* @note Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
int realTabIndex( QWidget* widget );

/**
* Is called internally whenever a new tab has been inserted.
*
* Is used to keep track of currently available and visible tabs.
*
* @note Added in QGIS 2.18
*/
virtual void tabInserted( int index );

/**
* Is called internally whenever a tab has been removed.
*
* Is used to keep track of currently available and visible tabs.
*
* @note Added in QGIS 2.18
*/
virtual void tabRemoved( int index );
};
4 changes: 2 additions & 2 deletions src/core/qgsoptional.h
Expand Up @@ -16,11 +16,11 @@
#ifndef QGSOPTIONAL_H
#define QGSOPTIONAL_H


/**
* \ingroup core
*
* \brief
* QgsOptional is a container for other classes and adds an additional enabled/disabled flag.
* \brief QgsOptional is a container for other classes and adds an additional enabled/disabled flag.
*
* Often it is used for configuration options which can be enabled or disabled but also have
* more internal configuration information that should not be lost when disabling and re-enabling.
Expand Down
31 changes: 23 additions & 8 deletions src/gui/qgstabwidget.h
Expand Up @@ -22,7 +22,7 @@
* The QgsTabWidget class is the same as the QTabWidget but with additional methods to
* temporarily hide/show tabs.
*
* @note Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
class GUI_EXPORT QgsTabWidget : public QTabWidget
{
Expand All @@ -32,28 +32,28 @@ class GUI_EXPORT QgsTabWidget : public QTabWidget
/**
* Create a new QgsTabWidget with the optionally provided parent.
*
* @note Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
QgsTabWidget( QWidget *parent = nullptr );

/**
* Hides the tab with the given widget
*
* @note Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
void hideTab( QWidget* tab );

/**
* Shows the tab with the given widget
*
* @note Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
void showTab( QWidget* tab );

/**
* Control the visibility for the tab with the given widget.
*
* @note Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
void setTabVisible( QWidget* tab, bool visible );

Expand All @@ -62,12 +62,27 @@ class GUI_EXPORT QgsTabWidget : public QTabWidget
* This index is not the same as the one provided to insertTab and removeTab
* since these methods are not aware of hidden tabs.
*
* @note Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
int realTabIndex( QWidget* widget );

virtual void tabInserted( int index );
virtual void tabRemoved( int index );
/**
* Is called internally whenever a new tab has been inserted.
*
* Is used to keep track of currently available and visible tabs.
*
* @note Added in QGIS 2.18
*/
virtual void tabInserted( int index ) override;

/**
* Is called internally whenever a tab has been removed.
*
* Is used to keep track of currently available and visible tabs.
*
* @note Added in QGIS 2.18
*/
virtual void tabRemoved( int index ) override;

private:
void synchronizeIndexes();
Expand Down
10 changes: 4 additions & 6 deletions tests/src/python/test_qgstabwidget.py
Expand Up @@ -17,16 +17,14 @@

import qgis # NOQA

from qgis.testing import unittest
from qgis.testing import unittest, start_app
from qgis.gui import QgsTabWidget
from qgis.PyQt.QtGui import QApplication, QWidget
from qgis.PyQt.QtWidgets import QWidget

start_app()

class TestQgsTabWidget(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.app = QApplication([])
class TestQgsTabWidget(unittest.TestCase):

def setUp(self):
"""Run before each test."""
Expand Down

0 comments on commit 39f7c04

Please sign in to comment.