Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[options search] API refactoring
* avoid using lambdas and use dedicate class and subclasses for each widget type (lable, groupbox, tree, etc)
* this makes the code much more clearer
* allow creating custom highlight widgets with API
  • Loading branch information
3nids committed Feb 4, 2018
1 parent 213d4b7 commit 70f9c22
Show file tree
Hide file tree
Showing 11 changed files with 849 additions and 347 deletions.
2 changes: 2 additions & 0 deletions python/gui/gui_auto.sip
Expand Up @@ -160,6 +160,8 @@
%Include qgsnewgeopackagelayerdialog.sip
%Include qgsopacitywidget.sip
%Include qgsoptionsdialogbase.sip
%Include qgsoptionsdialoghighlightwidget.sip
%Include qgsoptionsdialoghighlightwidgetsimpl.sip
%Include qgsoptionswidgetfactory.sip
%Include qgsorderbydialog.sip
%Include qgsowssourceselect.sip
Expand Down
51 changes: 0 additions & 51 deletions python/gui/qgsoptionsdialogbase.sip.in
Expand Up @@ -13,57 +13,6 @@



class QgsSearchHighlightOptionWidget : QObject
{
%Docstring
Container for a widget to be used to search text in the option dialog
If the widget type is handled, it is valid.
It can perform a text search in the widget and highlight it in case of success.
This uses stylesheets.

.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsoptionsdialogbase.h"
%End
public:

explicit QgsSearchHighlightOptionWidget( QWidget *widget = 0 );
%Docstring
Constructor

:param widget: the widget used to search text into
%End

bool isValid();
%Docstring
Returns if it valid: if the widget type is handled and if the widget is not still available
%End

bool searchHighlight( const QString &searchText );
%Docstring
search for a text pattern and highlight the widget if the text is found

:return: true if the text pattern is found
%End

void reset();
%Docstring
reset the style to the original state
%End

QWidget *widget();
%Docstring
return the widget
%End

virtual bool eventFilter( QObject *obj, QEvent *event );


};



class QgsOptionsDialogBase : QDialog
{
Expand Down
86 changes: 86 additions & 0 deletions python/gui/qgsoptionsdialoghighlightwidget.sip.in
@@ -0,0 +1,86 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsoptionsdialoghighlightwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsOptionsDialogHighlightWidget : QObject
{
%Docstring
Container for a widget to be used to search text in the option dialog
If the widget type is handled, it is valid.
It can perform a text search in the widget and highlight it in case of success.
This uses stylesheets.

.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsoptionsdialoghighlightwidget.h"
%End
public:
static QgsOptionsDialogHighlightWidget *createWidget( QWidget *widget ) /Factory/;

bool isValid();
%Docstring
Returns if it valid: if the widget type is handled and if the widget is not still available
%End

bool searchHighlight( const QString &text );
%Docstring
search for a text pattern and highlight the widget if the text is found

:return: true if the text pattern is found
%End

QWidget *widget();
%Docstring
Return the widget
%End


virtual bool eventFilter( QObject *obj, QEvent *event );



protected:

virtual bool searchText( const QString &text ) = 0;
%Docstring
Search for the ``text`` in the widget and return true if it was found
%End

virtual bool highlightText( const QString &text ) = 0;
%Docstring
Highlight the ``text`` in the widget.

:return: true if the text could be highlighted.
%End

virtual void reset() = 0;
%Docstring
reset the style of the widgets to its original state
%End

explicit QgsOptionsDialogHighlightWidget( QWidget *widget = 0 );
%Docstring
Constructor

:param widget: the widget used to search text into
%End


};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsoptionsdialoghighlightwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
127 changes: 127 additions & 0 deletions python/gui/qgsoptionsdialoghighlightwidgetsimpl.sip.in
@@ -0,0 +1,127 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsoptionsdialoghighlightwidgetsimpl.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/







class QgsOptionsDialogHighlightLabel : QgsOptionsDialogHighlightWidget
{
%Docstring
A highlight widget for labels.
This is used to search and highlight text in QgsOptionsDialogBase implementations.
%End

%TypeHeaderCode
#include "qgsoptionsdialoghighlightwidgetsimpl.h"
%End
public:
QgsOptionsDialogHighlightLabel( QLabel *label );
%Docstring
constructs a highlight widget for a label
%End
protected:
virtual bool searchText( const QString &text );
virtual bool highlightText( const QString &text );
virtual void reset();
};

class QgsOptionsDialogHighlightCheckBox : QgsOptionsDialogHighlightWidget
{
%Docstring
A highlight widget for checkboxes.
This is used to search and highlight text in QgsOptionsDialogBase implementations.
%End

%TypeHeaderCode
#include "qgsoptionsdialoghighlightwidgetsimpl.h"
%End
public:
QgsOptionsDialogHighlightCheckBox( QCheckBox *checkBox );
%Docstring
constructs a highlight widget for a checkbox
%End
protected:
virtual bool searchText( const QString &text );
virtual bool highlightText( const QString &text );
virtual void reset();
};

class QgsOptionsDialogHighlightButton : QgsOptionsDialogHighlightWidget
{
%Docstring
A highlight widget for buttons.
This is used to search and highlight text in QgsOptionsDialogBase implementations.
%End

%TypeHeaderCode
#include "qgsoptionsdialoghighlightwidgetsimpl.h"
%End
public:
QgsOptionsDialogHighlightButton( QAbstractButton *button );
%Docstring
constructs a highlight widget for a button.
%End
protected:
virtual bool searchText( const QString &text );
virtual bool highlightText( const QString &text );
virtual void reset();
};

class QgsOptionsDialogHighlightGroupBox : QgsOptionsDialogHighlightWidget
{
%Docstring
A highlight widget for group boxes.
This is used to search and highlight text in QgsOptionsDialogBase implementations.
%End

%TypeHeaderCode
#include "qgsoptionsdialoghighlightwidgetsimpl.h"
%End
public:
QgsOptionsDialogHighlightGroupBox( QGroupBox *groupBox );
%Docstring
constructs a highlight widget for a group box.
%End
protected:
virtual bool searchText( const QString &text );
virtual bool highlightText( const QString &text );
virtual void reset();
};

class QgsOptionsDialogHighlightTree : QgsOptionsDialogHighlightWidget
{
%Docstring
A highlight widget for trees.
This is used to search and highlight text in QgsOptionsDialogBase implementations.
Highlighting is only available for tree widgets only while searching can be performed
in any tree view or inherited class.
%End

%TypeHeaderCode
#include "qgsoptionsdialoghighlightwidgetsimpl.h"
%End
public:
QgsOptionsDialogHighlightTree( QTreeView *treeView );
%Docstring
constructs a highlight widget for a tree view or widget.
%End
protected:
virtual bool searchText( const QString &text );
virtual bool highlightText( const QString &text );
virtual void reset();
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsoptionsdialoghighlightwidgetsimpl.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
4 changes: 4 additions & 0 deletions src/gui/CMakeLists.txt
Expand Up @@ -314,6 +314,8 @@ SET(QGIS_GUI_SRCS
qgsnewgeopackagelayerdialog.cpp
qgsopacitywidget.cpp
qgsoptionsdialogbase.cpp
qgsoptionsdialoghighlightwidget.cpp
qgsoptionsdialoghighlightwidgetsimpl.cpp
qgsorderbydialog.cpp
qgsowssourceselect.cpp
qgspanelwidget.cpp
Expand Down Expand Up @@ -479,6 +481,8 @@ SET(QGIS_GUI_MOC_HDRS
qgsnewgeopackagelayerdialog.h
qgsopacitywidget.h
qgsoptionsdialogbase.h
qgsoptionsdialoghighlightwidget.h
qgsoptionsdialoghighlightwidgetsimpl.h
qgsoptionswidgetfactory.h
qgsorderbydialog.h
qgsowssourceselect.h
Expand Down

0 comments on commit 70f9c22

Please sign in to comment.