Skip to content
Permalink
Browse files
custom widgets for Qt Designer, QgsScaleVisibilityGroupBox plugin
  • Loading branch information
3nids committed May 12, 2014
1 parent 156dc55 commit 2cf3e7c5dda2e9748acf2429228c84a8c6ac04cf
@@ -46,6 +46,8 @@ IF(WITH_MAPSERVER)
SET (MAPSERVER_SKIP_ECW FALSE CACHE BOOL "Determines whether QGIS mapserver should disable ECW (ECW in server apps requires a special license)")
ENDIF(WITH_MAPSERVER)

SET (WITH_CUSTOM_WIDGETS FALSE CACHE BOOL "Determines whether QGIS custom widgets for Qt Designer should be built")

# build our version of astyle
SET (WITH_ASTYLE FALSE CACHE BOOL "If you plan to contribute you should reindent with scripts/prepare-commit.sh (using 'our' astyle)")

@@ -229,10 +231,13 @@ SET(QT_USE_QTNETWORK 1)
SET(QT_USE_QTSVG 1)
SET(QT_USE_QTSQL 1)
SET(QT_USE_QTWEBKIT 1)
IF (WITH_CUSTOM_WIDGETS)
SET(QT_USE_QTDESIGNER 1)
ENDIF (WITH_CUSTOM_WIDGETS)

IF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND)
IF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND OR (WITH_CUSTOM_WIDGETS AND NOT QT_QTDESIGNER_FOUND))
MESSAGE(SEND_ERROR "Some Qt4 modules haven't been found!")
ENDIF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND)
ENDIF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND OR (WITH_CUSTOM_WIDGETS AND NOT QT_QTDESIGNER_FOUND))

IF (WITH_QTMOBILITY)
FIND_PACKAGE(QtMobility 1.1.0)
@@ -285,6 +290,12 @@ ENDIF (ENABLE_TESTS)

INCLUDE( ${QT_USE_FILE} )

IF (WITH_CUSTOM_WIDGETS)
ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_NO_DEBUG)
ADD_DEFINITIONS(-DQT_SHARED)
ENDIF (WITH_CUSTOM_WIDGETS)

# Disable automatic conversion from QString to ASCII 8-bit strings (char *)
# (Keeps code compatible with Qt/Mac/64bit)
ADD_DEFINITIONS(-DQT_NO_CAST_TO_ASCII)
@@ -506,6 +517,7 @@ ADD_DEFINITIONS("-DCORE_EXPORT=${DLLIMPORT}")
ADD_DEFINITIONS("-DGUI_EXPORT=${DLLIMPORT}")
ADD_DEFINITIONS("-DPYTHON_EXPORT=${DLLIMPORT}")
ADD_DEFINITIONS("-DANALYSIS_EXPORT=${DLLIMPORT}")
ADD_DEFINITIONS("-DCUSTOMWIDGETS_EXPORT=${DLLIMPORT}")
ADD_DEFINITIONS("-DAPP_EXPORT=${DLLIMPORT}")

#############################################################
@@ -533,6 +545,7 @@ SET (QGIS_LIBEXEC_DIR ${QGIS_LIBEXEC_SUBDIR})
SET (QGIS_DATA_DIR ${QGIS_DATA_SUBDIR})
SET (QGIS_PLUGIN_DIR ${QGIS_PLUGIN_SUBDIR})
SET (QGIS_INCLUDE_DIR ${QGIS_INCLUDE_SUBDIR})
SET (QGIS_CUSTOMWIDGETS_DIR ${QT_PLUGINS_DIR}/designer)

# set the default locations where the targets (executables, libraries) will land when compiled
# this is to allow running qgis from the source tree without having to actually do a "make install"
@@ -589,7 +602,7 @@ ENDIF (NOT EXISTS QSCINTILLA_VERSION_STR AND EXISTS QSCI_MOD_VERSION_STR)
# installed with app target

CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake_templates/qgsconfig.h.in ${CMAKE_BINARY_DIR}/qgsconfig.h)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
INCLUDE_DIRECTORIES(${QT_INCLUDES} ${CMAKE_BINARY_DIR})

# Added by Jef to prevent python core and gui libs linking to other qgisCore and qgisGui libs
# that may be in the same install prefix
@@ -20,6 +20,10 @@ IF (WITH_MAPSERVER)
ADD_SUBDIRECTORY(mapserver) # TODO: enable again once compilation is fixed
ENDIF (WITH_MAPSERVER)

IF (WITH_CUSTOM_WIDGETS)
ADD_SUBDIRECTORY(customwidgets)
ENDIF (WITH_CUSTOM_WIDGETS)

IF (WITH_ASTYLE)
ADD_SUBDIRECTORY(astyle)
ENDIF(WITH_ASTYLE)
@@ -81,8 +81,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
// and connecting QDialogButtonBox's accepted/rejected signals to dialog's accept/reject slots
initOptionsBase( false );

mMaximumScaleIconLabel->setPixmap( QgsApplication::getThemePixmap( "/mActionZoomIn.svg" ) );
mMinimumScaleIconLabel->setPixmap( QgsApplication::getThemePixmap( "/mActionZoomOut.svg" ) );


connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
@@ -360,7 +359,7 @@ void QgsVectorLayerProperties::syncToLayer( void )
"layer is shown here. To enter or modify the query, click on the Query Builder button" ) );

//see if we are dealing with a pg layer here
grpSubset->setEnabled( true );
mSubsetGroupBox->setEnabled( true );
txtSubsetSQL->setText( layer->subsetString() );
// if the user is allowed to type an adhoc query, the app will crash if the query
// is bad. For this reason, the sql box is disabled and the query must be built
@@ -386,16 +385,9 @@ void QgsVectorLayerProperties::syncToLayer( void )
setDisplayField( layer-> displayField() );

// set up the scale based layer visibility stuff....
chkUseScaleDependentRendering->setChecked( layer->hasScaleBasedVisibility() );
bool projectScales = QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" );
if ( projectScales )
{
QStringList scalesList = QgsProject::instance()->readListEntry( "Scales", "/ScalesList" );
cbMinimumScale->updateScales( scalesList );
cbMaximumScale->updateScales( scalesList );
}
cbMinimumScale->setScale( 1.0 / layer->minimumScale() );
cbMaximumScale->setScale( 1.0 / layer->maximumScale() );
mScaleVisibilityWidget->setFromLayer( layer );
mScaleVisibilityGroupBox->setChecked( layer->hasScaleBasedVisibility() );
mScaleVisibilityWidget->setMapCanvas( QgisApp::instance()->mapCanvas() );

// get simplify drawing configuration
const QgsVectorSimplifyMethod& simplifyMethod = layer->simplifyMethod();
@@ -491,7 +483,7 @@ void QgsVectorLayerProperties::apply()
//
// Set up sql subset query if applicable
//
grpSubset->setEnabled( true );
mSubsetGroupBox->setEnabled( true );

if ( txtSubsetSQL->toPlainText() != layer->subsetString() )
{
@@ -501,9 +493,9 @@ void QgsVectorLayerProperties::apply()
}

// set up the scale based layer visibility stuff....
layer->toggleScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
layer->setMinimumScale( 1.0 / cbMinimumScale->scale() );
layer->setMaximumScale( 1.0 / cbMaximumScale->scale() );
layer->toggleScaleBasedVisibility( mScaleVisibilityGroupBox->isChecked() );
layer->setMinimumScale( 1.0 / mScaleVisibilityWidget->minimumScale() );
layer->setMaximumScale( 1.0 / mScaleVisibilityWidget->maximumScale() );

// provider-specific options
if ( layer->dataProvider() )
@@ -1110,16 +1102,6 @@ void QgsVectorLayerProperties::enableLabelOptions( bool theFlag )
labelOptionsFrame->setEnabled( theFlag );
}

void QgsVectorLayerProperties::on_mMinimumScaleSetCurrentPushButton_clicked()
{
cbMinimumScale->setScale( 1.0 / QgisApp::instance()->mapCanvas()->mapSettings().scale() );
}

void QgsVectorLayerProperties::on_mMaximumScaleSetCurrentPushButton_clicked()
{
cbMaximumScale->setScale( 1.0 / QgisApp::instance()->mapCanvas()->mapSettings().scale() );
}

void QgsVectorLayerProperties::on_mSimplifyDrawingGroupBox_toggled( bool checked )
{
if ( !( layer->dataProvider()->capabilities() & QgsVectorDataProvider::SimplifyGeometries ) )
@@ -20,6 +20,7 @@
#define QGSVECTORLAYERPROPERTIES

#include "qgsoptionsdialogbase.h"
#include "qgsscalevisibilitywidget.h"
#include "ui_qgsvectorlayerpropertiesbase.h"
#include "qgisgui.h"
#include "qgsaddattrdialog.h"
@@ -116,9 +117,6 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
void on_mButtonAddJoin_clicked();
void on_mButtonRemoveJoin_clicked();

void on_mMinimumScaleSetCurrentPushButton_clicked();
void on_mMaximumScaleSetCurrentPushButton_clicked();

void on_mSimplifyDrawingGroupBox_toggled( bool checked );

signals:
@@ -0,0 +1,103 @@

########################################################
# Files

SET (QGIS_CUSTOMWIDGETS_SRCS
qgiscustomwidgets.cpp
qgscollapsiblegroupboxplugin.cpp
qgsscalevisibilitywidgetplugin.cpp
)

SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
qgiscustomwidgets.h
qgscollapsiblegroupboxplugin.h
qgsscalevisibilitywidgetplugin.h
)

QT4_WRAP_CPP(QGIS_CUSTOMWIDGETS_MOC_SRCS ${QGIS_CUSTOMWIDGETS_MOC_HDRS})

IF(UNIX)
SET_SOURCE_FILES_PROPERTIES(${QGIS_CUSTOMWIDGETS_MOC_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations" )
ENDIF(UNIX)

SET(QGIS_CUSTOMWIDGETS_HDRS
qgiscustomwidgets.h
qgscollapsiblegroupboxplugin.h
qgsscalevisibilitywidgetplugin.h
)

SET(QGIS_CUSTOMWIDGETS_UI_HDRS
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsscalevisibilitygroupbox.h
)

INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../core/
${CMAKE_CURRENT_SOURCE_DIR}/../gui/
${CMAKE_CURRENT_BINARY_DIR}/../ui
)

IF (WIN32)
IF (MSVC)
ADD_DEFINITIONS("-DCUSTOMWIDGETS_EXPORT=${DLLEXPORT}")
ELSE (MSVC)
ADD_DEFINITIONS("-UCUSTOMWIDGETS_EXPORT \"-DCUSTOMWIDGETS_EXPORT=${DLLEXPORT}\"")
ENDIF (MSVC)
ENDIF (WIN32)


#############################################################
# qgis_customwidgets library

ADD_LIBRARY(qgis_customwidgets SHARED ${QGIS_CUSTOMWIDGETS_SRCS} ${QGIS_CUSTOMWIDGETS_MOC_SRCS} ${QGIS_CUSTOMWIDGETS_HDRS})

IF(NOT APPLE)
INSTALL(FILES ${QGIS_CUSTOMWIDGETS_HDRS} DESTINATION ${QGIS_INCLUDE_DIR})
ELSE(NOT APPLE)
SET_TARGET_PROPERTIES(qgis_customwidgets PROPERTIES
# no moc headers, messes up PROPERTIES syntax
CLEAN_DIRECT_OUTPUT 1
FRAMEWORK 1
FRAMEWORK_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}"
MACOSX_FRAMEWORK_INFO_PLIST "${CMAKE_SOURCE_DIR}/mac/framework.info.plist.in"
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${COMPLETE_VERSION}
MACOSX_FRAMEWORK_IDENTIFIER org.qgis.qgis2_customwidgets
BUILD_WITH_INSTALL_RPATH TRUE
PUBLIC_HEADER "${QGIS_CUSTOMWIDGETS_HDRS}"
LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
)
ENDIF(NOT APPLE)

#generate unversioned libs for android
IF (NOT ANDROID)
SET_TARGET_PROPERTIES(qgis_customwidgets PROPERTIES
VERSION ${COMPLETE_VERSION}
SOVERSION ${COMPLETE_VERSION}
)
ENDIF (NOT ANDROID)

# make sure that UI files will be processed first
ADD_DEPENDENCIES(qgis_customwidgets ui)

TARGET_LINK_LIBRARIES(qgis_customwidgets qgis_gui)


# install

INSTALL(TARGETS qgis_customwidgets
LIBRARY DESTINATION ${QGIS_CUSTOMWIDGETS_DIR}
PUBLIC_HEADER DESTINATION ${QGIS_INCLUDE_DIR})

# ui headers to install, don't exist at target definition time, install manually
IF (APPLE)
INSTALL(FILES ${QGIS_CUSTOMWIDGETS_UI_HDRS} DESTINATION ${QGIS_FW_SUBDIR}/qgis_gui.framework/Headers)
ELSE (APPLE)
INSTALL(FILES ${QGIS_CUSTOMWIDGETS_UI_HDRS} DESTINATION ${QGIS_INCLUDE_DIR})
ENDIF (APPLE)

# Mac dev frameworks
#IF (APPLE AND QGIS_MACAPP_INSTALL_DEV)
# INSTALL(TARGETS qgis_customwidgets FRAMEWORK DESTINATION ${QGIS_MACAPP_DEV_PREFIX})
# INSTALL(CODE "EXECUTE_PROCESS(COMMAND install_name_tool -id \"${QGIS_MACAPP_DEV_PREFIX}/qgis_customwidgets.framework/Versions/${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}/qgis_customwidgets\" \"$ENV{DESTDIR}${QGIS_MACAPP_DEV_PREFIX}/qgis_customwidgets.framework/qgis_customwidgets\")")
# INSTALL(CODE "EXECUTE_PROCESS(COMMAND install_name_tool -change \"${CMAKE_INSTALL_NAME_DIR}/qgis_core.framework/Versions/${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}/qgis_core\" \"${QGIS_MACAPP_DEV_PREFIX}/qgis_core.framework/Versions/${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}/qgis_core\" \"$ENV{DESTDIR}${QGIS_MACAPP_DEV_PREFIX}/qgis_customwidgets.framework/qgis_customwidgets\")")
#ENDIF (APPLE AND QGIS_MACAPP_INSTALL_DEV)
@@ -0,0 +1,36 @@
/***************************************************************************
qgscustomwidgets.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 "qplugin.h"

#include "qgiscustomwidgets.h"

#include "qgscollapsiblegroupboxplugin.h"
#include "qgsscalevisibilitywidgetplugin.h"


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

QList<QDesignerCustomWidgetInterface*> QgisCustomWidgets::customWidgets() const
{
return mWidgets;
}

Q_EXPORT_PLUGIN2( customwidgetsplugin, QgisCustomWidgets )
@@ -0,0 +1,38 @@
/***************************************************************************
qgscustomwidgets.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 QGISCUSTOMWIDGETS_H
#define QGISCUSTOMWIDGETS_H

#include <QDesignerCustomWidgetCollectionInterface>
#include <qplugin.h>

class QgisCustomWidgets : public QObject, public QDesignerCustomWidgetCollectionInterface
{
Q_OBJECT
Q_INTERFACES( QDesignerCustomWidgetCollectionInterface )

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

virtual QList<QDesignerCustomWidgetInterface*> customWidgets() const;

static QString groupName() {return "QGIS custom widgets";}

private:
QList<QDesignerCustomWidgetInterface*> mWidgets;
};

#endif // QGISCUSTOMWIDGETS_H

0 comments on commit 2cf3e7c

Please sign in to comment.