QGIS API Documentation  2.11.0-Master
qgsscalevisibilitydialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsscalevisibilitydialog.cpp
3  --------------------------------------
4  Date : 20.05.2014
5  Copyright : (C) 2014 Denis Rouzaud
6  Email : denis.rouzaud@gmail.com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15 
16 #include <QGridLayout>
17 #include <QDialogButtonBox>
18 
19 
21 
22 
23 
25  QDialog( parent )
26 {
27  if ( !title.isEmpty() )
28  {
29  setWindowTitle( title );
30  }
31 
32  QGridLayout* dlgLayout = new QGridLayout( this );
33  //dlgLayout->setContentsMargins( 0, 0, 0, 0 );
34 
35  mGroupBox = new QGroupBox( this );
36  mGroupBox->setCheckable( true );
37  mGroupBox->setTitle( tr( "Scale visibility " ) );
38 
39  QGridLayout* gbLayout = new QGridLayout( this );
40  //gbLayout->setContentsMargins( 0, 0, 0, 0 );
41 
42  mScaleWidget = new QgsScaleRangeWidget( this );
43  if ( mapCanvas )
44  {
45  mScaleWidget->setMapCanvas( mapCanvas );
46  }
47  gbLayout->addWidget( mScaleWidget, 0, 0 );
48  mGroupBox->setLayout( gbLayout );
49 
50  QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal, this );
51  connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
52  connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
53 
54  dlgLayout->addWidget( mGroupBox, 0, 0 );
55  dlgLayout->addWidget( buttonBox, 1, 0 );
56 }
57 
58 void QgsScaleVisibilityDialog::setScaleVisiblity( bool hasScaleVisibility )
59 {
60  mGroupBox->setChecked( hasScaleVisibility );
61 }
62 
64 {
65  return mGroupBox->isChecked();
66 }
67 
69 {
70  mScaleWidget->setMinimumScale( minScale );
71 }
72 
74 {
75  return mScaleWidget->minimumScale();
76 }
77 
79 {
80  mScaleWidget->setMaximumScale( maxScale );
81 }
82 
84 {
85  return mScaleWidget->maximumScale();
86 }
double minimumScale()
return the minimum scale
virtual void reject()
void addWidget(QWidget *widget, int row, int column, QFlags< Qt::AlignmentFlag > alignment)
void rejected()
bool hasScaleVisibility()
return if scale visibilty is enabled
void setMaximumScale(double scale)
void accepted()
QString tr(const char *sourceText, const char *disambiguation, int n)
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:105
void setMaximumScale(double maxScale)
set maximum scale (true scale, not scale denominator)
double maximumScale()
return maximum scale (true scale, not scale denominator)
void setChecked(bool checked)
void setLayout(QLayout *layout)
bool isEmpty() const
void setScaleVisiblity(bool hasScaleVisibility)
set if scale visibility is enabled
double maximumScale()
return the maximum scale
void setMinimumScale(double minScale)
set minimum scale (true scale, not scale denominator)
void setMinimumScale(double scale)
virtual void accept()
void setTitle(const QString &title)
void setCheckable(bool checkable)
QgsScaleVisibilityDialog(QWidget *parent=0, QString title=QString(), QgsMapCanvas *mapCanvas=0)
void setWindowTitle(const QString &)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setMapCanvas(QgsMapCanvas *mapCanvas)
set the map canvas which will be used for the current scale buttons
double minimumScale()
return minimum scale (true scale, not scale denominator)