Skip to content
Permalink
Browse files
Merge pull request #4299 from alexbruy/checkable-combobox
[FEATURE] New custom widget checkable combobox
  • Loading branch information
alexbruy committed Apr 10, 2017
2 parents fc2581c + 0803b56 commit 78d02b7fabfb19f7862d98fc7a1981875e626cca
@@ -37,6 +37,7 @@
%Include qgscodeeditorcss.sip
%End
%Include qgscharacterselectdialog.sip
%Include qgscheckablecombobox.sip
%Include qgscolorbrewercolorrampdialog.sip
%Include qgscolorbutton.sip
%Include qgscolorrampbutton.sip
@@ -0,0 +1,153 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgscheckablecombobox.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/








class QgsCheckableComboBox : QComboBox
{

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

QgsCheckableComboBox( QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsCheckableComboBox.
%End

QString separator() const;
%Docstring
Returns separator used to separate items in the display text.
\see setSeparator()
:rtype: str
%End

void setSeparator( const QString &separator );
%Docstring
Set separator used to separate items in the display text.
\param separator separator to use
\see separator()
%End

QString defaultText() const;
%Docstring
Returns default text which will be displayed in the widget
when no items selected.
\see setDefaultText()
:rtype: str
%End

void setDefaultText( const QString &text );
%Docstring
Set default text which will be displayed in the widget when
no items selected.
\param text default text
\see defaultText()
%End

QStringList checkedItems() const;
%Docstring
Returns currently checked items.
\see setCheckedItems()
:rtype: list of str
%End

Qt::CheckState itemCheckState( int index ) const;
%Docstring
Returns the checked state of the item identified by index
\param index item index
\see setItemCheckState()
\see toggleItemCheckState()
:rtype: Qt.CheckState
%End

void setItemCheckState( int index, Qt::CheckState state );
%Docstring
Sets the item check state to state
\param index item index
\param state check state
\see itemCheckState()
\see toggleItemCheckState()
%End

void toggleItemCheckState( int index );
%Docstring
Toggles the item check state
\param index item index
\see itemCheckState()
\see setItemCheckState()
%End

virtual void hidePopup();
%Docstring
Hides the list of items in the combobox if it is currently
visible and resets the internal state.
%End

virtual bool eventFilter( QObject *object, QEvent *event );
%Docstring
Filters events to enable context menu
:rtype: bool
%End

signals:

void checkedItemsChanged( const QStringList &items );
%Docstring
This signal is emitted whenever the checked items list changed.
%End

public slots:

void setCheckedItems( const QStringList &items );
%Docstring
Set items which should be checked/selected.
\param items items to select
\see checkedItems()
%End

protected:

virtual void resizeEvent( QResizeEvent *event );
%Docstring
Handler for widget resizing
%End

protected slots:

void showContextMenu( const QPoint &pos );
%Docstring
Display context menu which allows to select/deselect
all items at once.
%End

void selectAllOptions();
%Docstring
Selects all items.
%End

void deselectAllOptions();
%Docstring
Removes selection from all items.
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgscheckablecombobox.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -14,6 +14,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
qgiscustomwidgets.cpp
qgscollapsiblegroupboxplugin.cpp
qgscolorbuttonplugin.cpp
qgscheckablecomboboxplugin.cpp
qgsdatetimeeditplugin.cpp
qgsdockwidgetplugin.cpp
qgsdoublespinboxplugin.cpp
@@ -40,6 +41,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
qgiscustomwidgets.h
qgscollapsiblegroupboxplugin.h
qgscolorbuttonplugin.h
qgscheckablecomboboxplugin.h
qgsdatetimeeditplugin.h
qgsdockwidgetplugin.h
qgsdoublespinboxplugin.h
@@ -0,0 +1,97 @@
/***************************************************************************
qgscheckablecomboboxplugin.cpp
--------------------------------------
Date : March 22, 2017
Copyright : (C) 2017 Alexander Bruy
Email : alexander dot bruy at gmail 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 "qgiscustomwidgets.h"
#include "qgscheckablecombobox.h"
#include "qgscheckablecomboboxplugin.h"


QgsCheckableComboBoxPlugin::QgsCheckableComboBoxPlugin( QObject *parent )
: QObject( parent )
, mInitialized( false )
{
}


QString QgsCheckableComboBoxPlugin::name() const
{
return "QgsCheckableComboBox";
}

QString QgsCheckableComboBoxPlugin::group() const
{
return QgisCustomWidgets::groupName();
}

QString QgsCheckableComboBoxPlugin::includeFile() const
{
return "qgscheckablecombobox.h";
}

QIcon QgsCheckableComboBoxPlugin::icon() const
{
return QIcon( ":/images/icons/qgis-icon-60x60.png" );
}

bool QgsCheckableComboBoxPlugin::isContainer() const
{
return false;
}

QWidget *QgsCheckableComboBoxPlugin::createWidget( QWidget *parent )
{
return new QgsCheckableComboBox( parent );
}

bool QgsCheckableComboBoxPlugin::isInitialized() const
{
return mInitialized;
}

void QgsCheckableComboBoxPlugin::initialize( QDesignerFormEditorInterface *core )
{
Q_UNUSED( core );
if ( mInitialized )
return;
mInitialized = true;
}


QString QgsCheckableComboBoxPlugin::toolTip() const
{
return "";
}

QString QgsCheckableComboBoxPlugin::whatsThis() const
{
return "";
}

QString QgsCheckableComboBoxPlugin::domXml() const
{
return QString( "<ui language=\"c++\">\n"
" <widget class=\"%1\" name=\"mComboBox\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>160</width>\n"
" <height>27</height>\n"
" </rect>\n"
" </property>\n"
" </widget>\n"
"</ui>\n" )
.arg( name() );
}
@@ -0,0 +1,51 @@
/***************************************************************************
qgscheckablecomboboxplugin.h
--------------------------------------
Date : March 22, 2017
Copyright : (C) 2017 Alexander Bruy
Email : alexander dot bruy at gmail 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 QGSCHECKABLECOMBOBOXPLUGIN_H
#define QGSCHECKABLECOMBOBOXPLUGIN_H


#include <QtGlobal>
#include <QtUiPlugin/QDesignerCustomWidgetInterface>
#include <QtUiPlugin/QDesignerExportWidget>
#include "qgis_customwidgets.h"


class CUSTOMWIDGETS_EXPORT QgsCheckableComboBoxPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES( QDesignerCustomWidgetInterface )

public:
explicit QgsCheckableComboBoxPlugin( QObject *parent = 0 );

private:
bool mInitialized = false;

// QDesignerCustomWidgetInterface interface
public:
QString name() const override;
QString group() const override;
QString includeFile() const override;
QIcon icon() const override;
bool isContainer() const override;
QWidget *createWidget( QWidget *parent ) override;
bool isInitialized() const override;
void initialize( QDesignerFormEditorInterface *core ) override;
QString toolTip() const override;
QString whatsThis() const override;
QString domXml() const override;
};
#endif // QGSCHECKABLECOMBOBOXPLUGIN_H
@@ -1,5 +1,5 @@
/***************************************************************************
qgsfilterlineeditplugin.cpp
qgspasswordlineeditplugin.cpp
--------------------------------------
Date : March 13, 2017
Copyright : (C) 2017 Alexander Bruy
@@ -172,6 +172,7 @@ SET(QGIS_GUI_SRCS
qgsbrowsertreeview.cpp
qgsbusyindicatordialog.cpp
qgscharacterselectdialog.cpp
qgscheckablecombobox.cpp
qgscodeeditor.cpp
qgscodeeditorcss.cpp
qgscodeeditorhtml.cpp
@@ -329,6 +330,7 @@ SET(QGIS_GUI_MOC_HDRS
qgsbrowsertreeview.h
qgsbusyindicatordialog.h
qgscharacterselectdialog.h
qgscheckablecombobox.h
qgscodeeditor.h
qgscodeeditorcss.h
qgscodeeditorhtml.h
Loading

0 comments on commit 78d02b7

Please sign in to comment.