Skip to content
Permalink
Browse files
QgsScaleRangeWidget: renamed from QgsScaleVisibilityWidget, do not us…
…e ui file
  • Loading branch information
3nids committed May 12, 2014
1 parent f757bfd commit d83f3ec4e6b6db88f2b4daf5ec3970f75a02fc9d
@@ -385,9 +385,9 @@ void QgsVectorLayerProperties::syncToLayer( void )
setDisplayField( layer-> displayField() );

// set up the scale based layer visibility stuff....
mScaleVisibilityWidget->setFromLayer( layer );
mScaleRangeWidget->setFromLayer( layer );
mScaleVisibilityGroupBox->setChecked( layer->hasScaleBasedVisibility() );
mScaleVisibilityWidget->setMapCanvas( QgisApp::instance()->mapCanvas() );
mScaleRangeWidget->setMapCanvas( QgisApp::instance()->mapCanvas() );

// get simplify drawing configuration
const QgsVectorSimplifyMethod& simplifyMethod = layer->simplifyMethod();
@@ -494,8 +494,8 @@ void QgsVectorLayerProperties::apply()

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

// provider-specific options
if ( layer->dataProvider() )
@@ -20,7 +20,7 @@
#define QGSVECTORLAYERPROPERTIES

#include "qgsoptionsdialogbase.h"
#include "qgsscalevisibilitywidget.h"
#include "qgsscalerangewidget.h"
#include "ui_qgsvectorlayerpropertiesbase.h"
#include "qgisgui.h"
#include "qgsaddattrdialog.h"
@@ -12,7 +12,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
qgsfieldcomboboxplugin.cpp
qgsfieldexpressionwidgetplugin.cpp
qgsmaplayercomboboxplugin.cpp
qgsscalevisibilitywidgetplugin.cpp
qgsscalerangewidgetplugin.cpp
)

SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
@@ -21,7 +21,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
qgsfieldcomboboxplugin.h
qgsfieldexpressionwidgetplugin.h
qgsmaplayercomboboxplugin.h
qgsscalevisibilitywidgetplugin.h
qgsscalerangewidgetplugin.h
)

QT4_WRAP_CPP(QGIS_CUSTOMWIDGETS_MOC_SRCS ${QGIS_CUSTOMWIDGETS_MOC_HDRS})
@@ -36,11 +36,11 @@ SET(QGIS_CUSTOMWIDGETS_HDRS
qgsfieldcomboboxplugin.h
qgsfieldexpressionwidgetplugin.h
qgsmaplayercomboboxplugin.h
qgsscalevisibilitywidgetplugin.h
qgsscalerangewidgetplugin.h
)

SET(QGIS_CUSTOMWIDGETS_UI_HDRS
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsscalevisibilitywidget.h
# ${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsXXXwidget.h
)

INCLUDE_DIRECTORIES(
@@ -21,7 +21,7 @@
#include "qgsfieldcomboboxplugin.h"
#include "qgsfieldexpressionwidgetplugin.h"
#include "qgsmaplayercomboboxplugin.h"
#include "qgsscalevisibilitywidgetplugin.h"
#include "qgsscalerangewidgetplugin.h"


QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
@@ -37,7 +37,7 @@ QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
mWidgets.append( new QgsFieldComboBoxPlugin );
mWidgets.append( new QgsFieldExpressionWidgetPlugin );
mWidgets.append( new QgsMapLayerComboBoxPlugin );
mWidgets.append( new QgsScaleVisibilityWidgetPlugin );
mWidgets.append( new QgsScaleRangeWidgetPlugin );
}

QList<QDesignerCustomWidgetInterface*> QgisCustomWidgets::customWidgets() const
@@ -1,5 +1,5 @@
/***************************************************************************
qgsscalevisibilitywidgetplugin.cpp
qgsscalerangewidgetplugin.cpp
--------------------------------------
Date : 25.04.2014
Copyright : (C) 2014 Denis Rouzaud
@@ -14,53 +14,53 @@
***************************************************************************/

#include "qgiscustomwidgets.h"
#include "qgsscalevisibilitywidgetplugin.h"
#include "qgsscalevisibilitywidget.h"
#include "qgsscalerangewidgetplugin.h"
#include "qgsscalerangewidget.h"


QgsScaleVisibilityWidgetPlugin::QgsScaleVisibilityWidgetPlugin( QObject *parent )
QgsScaleRangeWidgetPlugin::QgsScaleRangeWidgetPlugin( QObject *parent )
: QObject( parent )
, mInitialized( false )
{
}


QString QgsScaleVisibilityWidgetPlugin::name() const
QString QgsScaleRangeWidgetPlugin::name() const
{
return "QgsScaleVisibilityWidget";
return "QgsScaleRangeWidget";
}

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

QString QgsScaleVisibilityWidgetPlugin::includeFile() const
QString QgsScaleRangeWidgetPlugin::includeFile() const
{
return "qgsscalevisibilitywidget.h";
return "qgsscalerangewidget.h";
}

QIcon QgsScaleVisibilityWidgetPlugin::icon() const
QIcon QgsScaleRangeWidgetPlugin::icon() const
{
return QIcon();
}

bool QgsScaleVisibilityWidgetPlugin::isContainer() const
bool QgsScaleRangeWidgetPlugin::isContainer() const
{
return false;
}

QWidget *QgsScaleVisibilityWidgetPlugin::createWidget( QWidget *parent )
QWidget *QgsScaleRangeWidgetPlugin::createWidget( QWidget *parent )
{
return new QgsScaleVisibilityWidget( parent );
return new QgsScaleRangeWidget( parent );
}

bool QgsScaleVisibilityWidgetPlugin::isInitialized() const
bool QgsScaleRangeWidgetPlugin::isInitialized() const
{
return mInitialized;
}

void QgsScaleVisibilityWidgetPlugin::initialize( QDesignerFormEditorInterface *core )
void QgsScaleRangeWidgetPlugin::initialize( QDesignerFormEditorInterface *core )
{
Q_UNUSED( core );
if ( mInitialized )
@@ -69,20 +69,20 @@ void QgsScaleVisibilityWidgetPlugin::initialize( QDesignerFormEditorInterface *c
}


QString QgsScaleVisibilityWidgetPlugin::toolTip() const
QString QgsScaleRangeWidgetPlugin::toolTip() const
{
return "A widget to define the scale visibility";
return "A widget to define the scale range";
}

QString QgsScaleVisibilityWidgetPlugin::whatsThis() const
QString QgsScaleRangeWidgetPlugin::whatsThis() const
{
return "A widget to define the scale visibility";
return "A widget to define the scale range.";
}

QString QgsScaleVisibilityWidgetPlugin::domXml() const
QString QgsScaleRangeWidgetPlugin::domXml() const
{
return QString( "<ui language=\"c++\">\n"
" <widget class=\"%1\" name=\"mScaleVisibilityWidget\">\n"
" <widget class=\"%1\" name=\"mScaleRangeWidget\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
@@ -1,5 +1,5 @@
/***************************************************************************
qgsscalevisibilitywidgetplugin.h
qgsscalerangewidgetplugin.h
--------------------------------------
Date : 25.04.2014
Copyright : (C) 2014 Denis Rouzaud
@@ -13,20 +13,20 @@
* *
***************************************************************************/

#ifndef QGSSCALEVISIBILITYWIDGETPLUGIN_H
#define QGSSCALEVISIBILITYWIDGETPLUGIN_H
#ifndef QGSSCALERANGEWIDGETPLUGIN_H
#define QGSSCALERANGEWIDGETPLUGIN_H

#include <QDesignerExportWidget>
#include <QDesignerCustomWidgetInterface>


class QDESIGNER_WIDGET_EXPORT QgsScaleVisibilityWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface
class QDESIGNER_WIDGET_EXPORT QgsScaleRangeWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES( QDesignerCustomWidgetInterface )

public:
explicit QgsScaleVisibilityWidgetPlugin( QObject *parent = 0 );
explicit QgsScaleRangeWidgetPlugin( QObject *parent = 0 );

private:
bool mInitialized;
@@ -45,4 +45,4 @@ class QDESIGNER_WIDGET_EXPORT QgsScaleVisibilityWidgetPlugin : public QObject, p
QString whatsThis() const;
QString domXml() const;
};
#endif // QGSSCALEVISIBILITYWIDGETPLUGIN_H
#endif // QGSSCALERANGEWIDGETPLUGIN_H
@@ -138,7 +138,7 @@ qgsrelationeditor.cpp
qgsrelationmanagerdialog.cpp
qgsrubberband.cpp
qgsscalecombobox.cpp
qgsscalevisibilitywidget.cpp
qgsscalerangewidget.cpp
qgssearchquerybuilder.cpp
qgssublayersdialog.cpp
qgssvgannotationitem.cpp
@@ -277,7 +277,7 @@ qgsrelationadddlg.h
qgsrelationeditor.h
qgsrelationmanagerdialog.h
qgsscalecombobox.h
qgsscalevisibilitywidget.h
qgsscalerangewidget.h
qgssearchquerybuilder.h
qgssublayersdialog.h
qgsunitselectionwidget.h
@@ -342,7 +342,7 @@ qgsprojectionselector.h
qgsrelationeditor.h
qgsrubberband.h
qgsscalecombobox.h
qgsscalevisibilitywidget.h
qgsscalerangewidget.h
qgssearchquerybuilder.h
qgssublayersdialog.h
qgsvectorlayertools.h
@@ -1,5 +1,5 @@
/***************************************************************************
qgsscalevisibilitywidget.cpp
qgsscalerangewidget.cpp
--------------------------------------
Date : 25.04.2014
Copyright : (C) 2014 Denis Rouzaud
@@ -13,28 +13,42 @@
* *
***************************************************************************/

#include "qgsscalevisibilitywidget.h"
#include "qgsscalerangewidget.h"
#include "qgsapplication.h"
#include "qgsproject.h"

QgsScaleVisibilityWidget::QgsScaleVisibilityWidget( QWidget *parent )

QgsScaleRangeWidget::QgsScaleRangeWidget( QWidget *parent )
: QWidget( parent )
, mCanvas( 0 )
{
setupUi( this );
mLayout = new QGridLayout( this );
mLayout->setContentsMargins( 0, 0, 0, 0 );

QLabel* maxLbl = new QLabel( tr("Maximimum (inclusive)"), this);
QLabel* minLbl = new QLabel( tr("Minimimum (exclusive)"), this);

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

mMinimumScaleSetCurrentPushButton->hide();
mMaximumScaleSetCurrentPushButton->hide();
mMaximumScaleComboBox = new QgsScaleComboBox(this);
mMinimumScaleComboBox = new QgsScaleComboBox(this);

mLayout->addWidget(maxLbl, 0, 0);
mLayout->addWidget(mMaximumScaleIconLabel, 0, 1);
mLayout->addWidget(mMaximumScaleComboBox, 0, 2);
mLayout->addWidget(minLbl, 0, 3);
mLayout->addWidget(mMinimumScaleIconLabel, 0, 4);
mLayout->addWidget(mMinimumScaleComboBox, 0, 5);
}

QgsScaleVisibilityWidget::~QgsScaleVisibilityWidget()
QgsScaleRangeWidget::~QgsScaleRangeWidget()
{
}

void QgsScaleVisibilityWidget::showEvent( QShowEvent * )
void QgsScaleRangeWidget::showEvent( QShowEvent * )
{
bool projectScales = QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" );
if ( projectScales )
@@ -45,47 +59,57 @@ void QgsScaleVisibilityWidget::showEvent( QShowEvent * )
}
}

void QgsScaleVisibilityWidget::setMapCanvas( QgsMapCanvas *mapCanvas )
void QgsScaleRangeWidget::setMapCanvas( QgsMapCanvas *mapCanvas )
{
if (mMinimumScaleSetCurrentPushButton)
delete mMinimumScaleSetCurrentPushButton;
if (mMaximumScaleSetCurrentPushButton)
delete mMaximumScaleSetCurrentPushButton;
if ( !mapCanvas )
return;

mCanvas = mapCanvas;
mMinimumScaleSetCurrentPushButton->show();
mMaximumScaleSetCurrentPushButton->show();

mMaximumScaleSetCurrentPushButton = new QToolButton();
connect( mMaximumScaleSetCurrentPushButton, SIGNAL(clicked()), this, SLOT(setMaxScaleFromCanvas()));
mMinimumScaleSetCurrentPushButton = new QToolButton();
connect( mMinimumScaleSetCurrentPushButton, SIGNAL(clicked()), this, SLOT(setMinScaleFromCanvas()));

mLayout->addWidget(mMaximumScaleSetCurrentPushButton, 1,2);
mLayout->addWidget(mMinimumScaleSetCurrentPushButton, 1,5);
}

void QgsScaleVisibilityWidget::setMinimumScale( double scale )
void QgsScaleRangeWidget::setMinimumScale( double scale )
{
mMinimumScaleComboBox->setScale( scale );
}

double QgsScaleVisibilityWidget::minimumScale()
double QgsScaleRangeWidget::minimumScale()
{
return mMinimumScaleComboBox->scale();
}

void QgsScaleVisibilityWidget::setMaximumScale( double scale )
void QgsScaleRangeWidget::setMaximumScale( double scale )
{
mMaximumScaleComboBox->setScale( scale );
}

double QgsScaleVisibilityWidget::maximumScale()
double QgsScaleRangeWidget::maximumScale()
{
return mMaximumScaleComboBox->scale();
}

void QgsScaleVisibilityWidget::on_mMinimumScaleSetCurrentPushButton_clicked()
void QgsScaleRangeWidget::setMinScaleFromCanvas()
{
mMinimumScaleComboBox->setScale( 1.0 / mCanvas->mapSettings().scale() );
}

void QgsScaleVisibilityWidget::on_mMaximumScaleSetCurrentPushButton_clicked()
void QgsScaleRangeWidget::setMaxScaleFromCanvas()
{
mMaximumScaleComboBox->setScale( 1.0 / mCanvas->mapSettings().scale() );
}

void QgsScaleVisibilityWidget::setFromLayer( QgsMapLayer *layer )
void QgsScaleRangeWidget::setFromLayer( QgsMapLayer *layer )
{
mMinimumScaleComboBox->setScale( 1.0 / layer->minimumScale() );
mMaximumScaleComboBox->setScale( 1.0 / layer->maximumScale() );

0 comments on commit d83f3ec

Please sign in to comment.