Skip to content
Permalink
Browse files

add expression builder to custom widgets

  • Loading branch information
3nids committed Nov 3, 2015
1 parent 1b170f9 commit 75e8bdc9b6687baad2ac10772dc3aaa274ba8b96
@@ -28,6 +28,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
qgsdatetimeeditplugin.cpp
qgsdatadefinedbuttonplugin.cpp
qgsdoublespinboxplugin.cpp
qgsexpressionbuilderwidgetplugin.cpp
qgsextentgroupboxplugin.cpp
qgsfieldcomboboxplugin.cpp
qgsfieldexpressionwidgetplugin.cpp
@@ -49,6 +50,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
qgsdatetimeeditplugin.h
qgsdatadefinedbuttonplugin.h
qgsdoublespinboxplugin.h
qgsexpressionbuilderwidgetplugin.h
qgsextentgroupboxplugin.h
qgsfieldcomboboxplugin.h
qgsfieldexpressionwidgetplugin.h
@@ -76,6 +78,7 @@ SET(QGIS_CUSTOMWIDGETS_HDRS
qgsdatetimeeditplugin.h
qgsdatadefinedbuttonplugin.h
qgsdoublespinboxplugin.h
qgsexpressionbuilderwidgetplugin.h
qgsextentgroupboxplugin.h
qgsfieldcomboboxplugin.h
qgsfieldexpressionwidgetplugin.h
@@ -23,6 +23,7 @@
#include "qgsdatadefinedbuttonplugin.h"
#include "qgsdatetimeeditplugin.h"
#include "qgsdoublespinboxplugin.h"
#include "qgsexpressionbuilderwidgetplugin.h"
#include "qgsextentgroupboxplugin.h"
#include "qgsfieldcomboboxplugin.h"
#include "qgsfieldexpressionwidgetplugin.h"
@@ -45,6 +46,7 @@ QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
mWidgets.append( new QgsDataDefinedButtonPlugin( this ) );
mWidgets.append( new QgsDateTimeEditPlugin( this ) );
mWidgets.append( new QgsDoubleSpinBoxPlugin( this ) );
mWidgets.append( new QgsExpressionBuilderWidgetPlugin( this ) );
mWidgets.append( new QgsExtentGroupBoxPlugin( this ) );
mWidgets.append( new QgsFieldComboBoxPlugin( this ) );
mWidgets.append( new QgsFieldExpressionWidgetPlugin( this ) );
@@ -0,0 +1,97 @@
/***************************************************************************
qgsexpressionbuilderwidgetplugin.cpp
--------------------------------------
Date : 03.11.2015
Copyright : (C) 2015 Denis Rouzaud
Email : denis.rouzaud@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 "qgsexpressionbuilderwidget.h"
#include "qgsexpressionbuilderwidgetplugin.h"


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


QString QgsExpressionBuilderWidgetPlugin::name() const
{
return "QgsExpressionBuilderWidget";
}

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

QString QgsExpressionBuilderWidgetPlugin::includeFile() const
{
return "qgsexpressionbuilderwidget.h";
}

QIcon QgsExpressionBuilderWidgetPlugin::icon() const
{
return QIcon();
}

bool QgsExpressionBuilderWidgetPlugin::isContainer() const
{
return true;
}

QWidget *QgsExpressionBuilderWidgetPlugin::createWidget( QWidget *parent )
{
return new QgsExpressionBuilderWidget( parent );
}

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

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


QString QgsExpressionBuilderWidgetPlugin::toolTip() const
{
return tr( "Edit expression" );
}

QString QgsExpressionBuilderWidgetPlugin::whatsThis() const
{
return tr( "Edit expression" );
}

QString QgsExpressionBuilderWidgetPlugin::domXml() const
{
return QString( "<ui language=\"c++\">\n"
" <widget class=\"%1\" name=\"mExpressionBuilderWidget\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>700</width>\n"
" <height>400</height>\n"
" </rect>\n"
" </property>\n"
" </widget>\n"
"</ui>\n" )
.arg( name() );
}
@@ -0,0 +1,48 @@
/***************************************************************************
qgsexpressionbuilderwidgetplugin.h
--------------------------------------
Date : 03.11.2015
Copyright : (C) 2015 Denis Rouzaud
Email : denis.rouzaud@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 QGSEXPRESSIONBUILDERWIDGETPLUGIN_H
#define QGSEXPRESSIONBUILDERWIDGETPLUGIN_H

#include <QDesignerExportWidget>
#include <QDesignerCustomWidgetInterface>


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

public:
explicit QgsExpressionBuilderWidgetPlugin( 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 // QGSEXPRESSIONBUILDERWIDGETPLUGIN_H

0 comments on commit 75e8bdc

Please sign in to comment.
You can’t perform that action at this time.