Skip to content
Permalink
Browse files
added QgsFieldComboBox, QgsFieldExpressionWidget and QgsMapLayerCombo…
…Box to custom widgets
  • Loading branch information
3nids committed May 12, 2014
1 parent 2cf3e7c commit ebe1f2e7d22821f03a2cfd94e55bf10be7fbb3f1
@@ -5,12 +5,18 @@
SET (QGIS_CUSTOMWIDGETS_SRCS
qgiscustomwidgets.cpp
qgscollapsiblegroupboxplugin.cpp
qgsfieldcomboboxplugin.cpp
qgsfieldexpressionwidgetplugin.cpp
qgsmaplayercomboboxplugin.cpp
qgsscalevisibilitywidgetplugin.cpp
)

SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
qgiscustomwidgets.h
qgscollapsiblegroupboxplugin.h
qgsfieldcomboboxplugin.h
qgsfieldexpressionwidgetplugin.h
qgsmaplayercomboboxplugin.h
qgsscalevisibilitywidgetplugin.h
)

@@ -23,6 +29,9 @@ ENDIF(UNIX)
SET(QGIS_CUSTOMWIDGETS_HDRS
qgiscustomwidgets.h
qgscollapsiblegroupboxplugin.h
qgsfieldcomboboxplugin.h
qgsfieldexpressionwidgetplugin.h
qgsmaplayercomboboxplugin.h
qgsscalevisibilitywidgetplugin.h
)

@@ -18,13 +18,19 @@
#include "qgiscustomwidgets.h"

#include "qgscollapsiblegroupboxplugin.h"
#include "qgsfieldcomboboxplugin.h"
#include "qgsfieldexpressionwidgetplugin.h"
#include "qgsmaplayercomboboxplugin.h"
#include "qgsscalevisibilitywidgetplugin.h"


QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
: QObject( parent )
{
mWidgets.append( new QgsCollapsibleGroupBoxPlugin );
mWidgets.append( new QgsFieldComboBoxPlugin );
mWidgets.append( new QgsFieldExpressionWidgetPlugin );
mWidgets.append( new QgsMapLayerComboBoxPlugin );
mWidgets.append( new QgsScaleVisibilityWidgetPlugin );
}

@@ -0,0 +1,105 @@
/***************************************************************************
qgsfieldcomboboxplugin.cpp
--------------------------------------
Date : 25.04.2014
Copyright : (C) 2014 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 "qgsfieldcombobox.h"
#include "qgsfieldcomboboxplugin.h"


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


QString QgsFieldComboBoxPlugin::name() const
{
return "QgsFieldComboBox";
}

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

QString QgsFieldComboBoxPlugin::includeFile() const
{
return "qgsfieldcombobox.h";
}

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

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

QWidget *QgsFieldComboBoxPlugin::createWidget( QWidget *parent )
{
return new QgsFieldComboBox( parent );
}

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

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


QString QgsFieldComboBoxPlugin::toolTip() const
{
return "A combo box to list the fields of a layer";
}

QString QgsFieldComboBoxPlugin::whatsThis() const
{
return "A combo box to list the field of a layer.";
}

QString QgsFieldComboBoxPlugin::domXml() const
{
return QString( "<ui language=\"c++\">\n"
" <widget class=\"%1\" name=\"mFieldComboBox\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>300</width>\n"
" <height>100</height>\n"
" </rect>\n"
" </property>\n"
" <property name=\"toolTip\" >\n"
" <string>%2</string>\n"
" </property>\n"
" <property name=\"whatsThis\" >\n"
" <string>%3.</string>\n"
" </property>\n"
" </widget>\n"
"</ui>\n" )
.arg( name() )
.arg( toolTip() )
.arg( whatsThis() );
}
@@ -0,0 +1,46 @@
/***************************************************************************
qgsfieldcomboboxplugin.h
--------------------------------------
Date : 25.04.2014
Copyright : (C) 2014 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 QGSFIELDCOMBOBOXPLUGIN_H
#define QGSFIELDCOMBOBOXPLUGIN_H

#include <QDesignerCustomWidgetInterface>

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

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

private:
bool mInitialized;

// QDesignerCustomWidgetInterface interface
public:
QString name() const;
QString group() const;
QString includeFile() const;
QIcon icon() const;
bool isContainer() const;
QWidget *createWidget( QWidget *parent );
bool isInitialized() const;
void initialize( QDesignerFormEditorInterface *core );
QString toolTip() const;
QString whatsThis() const;
QString domXml() const;
};
#endif // QGSFIELDCOMBOBOXPLUGIN_H
@@ -0,0 +1,105 @@
/***************************************************************************
qgsfieldexpressionwidgetplugin.cpp
--------------------------------------
Date : 25.04.2014
Copyright : (C) 2014 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 "qgsfieldexpressionwidgetplugin.h"
#include "qgsfieldexpressionwidget.h"


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


QString QgsFieldExpressionWidgetPlugin::name() const
{
return "QgsFieldExpressionWidget";
}

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

QString QgsFieldExpressionWidgetPlugin::includeFile() const
{
return "qgsfieldexpressionwidget.h";
}

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

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

QWidget *QgsFieldExpressionWidgetPlugin::createWidget( QWidget *parent )
{
return new QgsFieldExpressionWidget( parent );
}

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

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


QString QgsFieldExpressionWidgetPlugin::toolTip() const
{
return "An editable combo box to enter an expression";
}

QString QgsFieldExpressionWidgetPlugin::whatsThis() const
{
return "An editable combo box to enter an expression. A button allows opening the expression dialog. Expression are evaluated to detect errors.";
}

QString QgsFieldExpressionWidgetPlugin::domXml() const
{
return QString( "<ui language=\"c++\">\n"
" <widget class=\"%1\" name=\"mFieldExpressionWidget\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>300</width>\n"
" <height>100</height>\n"
" </rect>\n"
" </property>\n"
" <property name=\"toolTip\" >\n"
" <string>%2</string>\n"
" </property>\n"
" <property name=\"whatsThis\" >\n"
" <string>%3.</string>\n"
" </property>\n"
" </widget>\n"
"</ui>\n" )
.arg( name() )
.arg( toolTip() )
.arg( whatsThis() );
}
@@ -0,0 +1,46 @@
/***************************************************************************
qgsfieldexpressionwidgetplugin.h
--------------------------------------
Date : 25.04.2014
Copyright : (C) 2014 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 QGSFIELDEXPRESSIONWIDGETPLUGIN_H
#define QGSFIELDEXPRESSIONWIDGETPLUGIN_H

#include <QDesignerCustomWidgetInterface>

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

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

private:
bool mInitialized;

// QDesignerCustomWidgetInterface interface
public:
QString name() const;
QString group() const;
QString includeFile() const;
QIcon icon() const;
bool isContainer() const;
QWidget *createWidget( QWidget *parent );
bool isInitialized() const;
void initialize( QDesignerFormEditorInterface *core );
QString toolTip() const;
QString whatsThis() const;
QString domXml() const;
};
#endif // QGSFIELDEXPRESSIONWIDGETPLUGIN_H

0 comments on commit ebe1f2e

Please sign in to comment.