Skip to content
Permalink
Browse files
Add custom widget plugin for QgsRasterBandComboBox
  • Loading branch information
nyalldawson committed May 9, 2017
1 parent f4b353c commit 872cd13675fe20f3510108fc247e79c7afc53ac7
@@ -29,6 +29,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
qgspasswordlineeditplugin.cpp
qgsprojectionselectionwidgetplugin.cpp
qgspropertyoverridebuttonplugin.cpp
qgsrasterbandcomboboxplugin.cpp
qgsrelationeditorwidgetplugin.cpp
qgsrelationreferencewidgetplugin.cpp
qgsscalerangewidgetplugin.cpp
@@ -56,6 +57,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
qgspasswordlineeditplugin.h
qgsprojectionselectionwidgetplugin.h
qgspropertyoverridebuttonplugin.h
qgsrasterbandcomboboxplugin.h
qgsrelationeditorwidgetplugin.h
qgsrelationreferencewidgetplugin.h
qgsscalerangewidgetplugin.h
@@ -87,6 +89,7 @@ SET(QGIS_CUSTOMWIDGETS_HDRS
qgsmaplayercomboboxplugin.h
qgsprojectionselectionwidgetplugin.h
qgspropertyoverridebuttonplugin.h
qgsrasterbandcomboboxplugin.h
qgsrelationeditorwidgetplugin.h
qgsrelationreferencewidgetplugin.h
qgsscalerangewidgetplugin.h
@@ -109,7 +112,9 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/../gui/attributetable/
${CMAKE_CURRENT_SOURCE_DIR}/../gui/editorwidgets/
${CMAKE_CURRENT_SOURCE_DIR}/../gui/editorwidgets/core
${CMAKE_CURRENT_SOURCE_DIR}/../gui/raster/
${CMAKE_BINARY_DIR}/src/core
${CMAKE_BINARY_DIR}/src/core/raster/
${CMAKE_BINARY_DIR}/src/gui
${CMAKE_BINARY_DIR}/src/customwidgets
${CMAKE_CURRENT_BINARY_DIR}/../ui/
@@ -30,6 +30,7 @@
#include "qgsmaplayercomboboxplugin.h"
#include "qgsprojectionselectionwidgetplugin.h"
#include "qgspropertyoverridebuttonplugin.h"
#include "qgsrasterbandcomboboxplugin.h"
#include "qgsrelationeditorwidgetplugin.h"
#include "qgsrelationreferencewidgetplugin.h"
#include "qgsscalerangewidgetplugin.h"
@@ -54,6 +55,7 @@ QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
mWidgets.append( new QgsMapLayerComboBoxPlugin( this ) );
mWidgets.append( new QgsProjectionSelectionWidgetPlugin( this ) );
mWidgets.append( new QgsPropertyOverrideButtonPlugin( this ) );
mWidgets.append( new QgsRasterBandComboBoxPlugin( this ) );
mWidgets.append( new QgsRelationEditorWidgetPlugin( this ) );
mWidgets.append( new QgsRelationReferenceWidgetPlugin( this ) );
mWidgets.append( new QgsScaleRangeWidgetPlugin( this ) );
@@ -0,0 +1,97 @@
/***************************************************************************
qgsrasterbandcomboboxplugin.cpp
--------------------------------------
Date : 09.05.2017
Copyright : (C) 2017 Nyall Dawson
Email : nyall.dawson@gmail.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 "qgsrasterbandcombobox.h"
#include "qgsrasterbandcomboboxplugin.h"


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


QString QgsRasterBandComboBoxPlugin::name() const
{
return "QgsRasterBandComboBox";
}

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

QString QgsRasterBandComboBoxPlugin::includeFile() const
{
return "qgsrasterbandcombobox.h";
}

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

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

QWidget *QgsRasterBandComboBoxPlugin::createWidget( QWidget *parent )
{
return new QgsRasterBandComboBox( parent );
}

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

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


QString QgsRasterBandComboBoxPlugin::toolTip() const
{
return tr( "A combo box to list the bands from a raster layer" );
}

QString QgsRasterBandComboBoxPlugin::whatsThis() const
{
return tr( "A combo box to list the bands from a raster layer." );
}

QString QgsRasterBandComboBoxPlugin::domXml() const
{
return QString( "<ui language=\"c++\">\n"
" <widget class=\"%1\" name=\"mRasterBandComboBox\">\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 @@
/***************************************************************************
qgsrasterbandcomboboxplugin.h
--------------------------------------
Date : 09.05.2017
Copyright : (C) 2017 Nyall Dawson
Email : nyall.dawson@gmail.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 QGSRASTERBANDCOMBOBOXPLUGIN_H
#define QGSRASTERBANDCOMBOBOXPLUGIN_H


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


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

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

private:
bool mInitialized;

// 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 // QGSRASTERBANDCOMBOBOXPLUGIN_H
@@ -18,7 +18,7 @@

#include "qgis_gui.h"
#include "qgis_sip.h"
#include "qgsrasterlayer.h"
#include "raster/qgsrasterlayer.h"
#include <QComboBox>

class QgsMapLayer;

0 comments on commit 872cd13

Please sign in to comment.