mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
[FEATURE] project scale list (if used - overrides global predefined scales)
This commit is contained in:
parent
c4299f4bee
commit
fc3e49b8a3
@ -2973,6 +2973,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
|
||||
mMapCanvas->freeze( false );
|
||||
mMapCanvas->refresh();
|
||||
mMapCanvas->clearExtentHistory();
|
||||
mScaleEdit->updateScales();
|
||||
|
||||
// set project CRS
|
||||
QgsMapRenderer* myRenderer = mMapCanvas->mapRenderer();
|
||||
@ -3107,6 +3108,13 @@ void QgisApp::fileOpen()
|
||||
}
|
||||
|
||||
setTitleBarText_( *this );
|
||||
|
||||
bool projectScales = QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" );
|
||||
if ( projectScales )
|
||||
{
|
||||
mScaleEdit->updateScales( QgsProject::instance()->readListEntry( "Scales", "/ScalesList" ) );
|
||||
}
|
||||
|
||||
emit projectRead(); // let plug-ins know that we've read in a new
|
||||
// project so that they can check any project
|
||||
// specific plug-in state
|
||||
@ -3117,7 +3125,6 @@ void QgisApp::fileOpen()
|
||||
mMapCanvas->freeze( false );
|
||||
mMapCanvas->refresh();
|
||||
}
|
||||
|
||||
} // QgisApp::fileOpen
|
||||
|
||||
|
||||
@ -3170,6 +3177,13 @@ bool QgisApp::addProject( QString projectFile )
|
||||
int myAlpha = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorAlphaPart", defaultAlpha );
|
||||
QgsRenderer::setSelectionColor( QColor( myRed, myGreen, myBlue, myAlpha ) );
|
||||
|
||||
//load project scales
|
||||
bool projectScales = QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" );
|
||||
if ( projectScales )
|
||||
{
|
||||
mScaleEdit->updateScales( QgsProject::instance()->readListEntry( "Scales", "/ScalesList" ) );
|
||||
}
|
||||
|
||||
mMapCanvas->updateScale();
|
||||
QgsDebugMsg( "Scale restored..." );
|
||||
|
||||
@ -3302,12 +3316,10 @@ void QgisApp::fileSaveAs()
|
||||
}
|
||||
} // QgisApp::fileSaveAs
|
||||
|
||||
|
||||
// Open the project file corresponding to the
|
||||
// path at the given index in mRecentProjectPaths
|
||||
void QgisApp::openProject( QAction *action )
|
||||
{
|
||||
|
||||
// possibly save any pending work before opening a different project
|
||||
QString debugme;
|
||||
assert( action != NULL );
|
||||
@ -3323,7 +3335,6 @@ void QgisApp::openProject( QAction *action )
|
||||
int myProjectionEnabledFlag =
|
||||
QgsProject::instance()->readNumEntry( "SpatialRefSys", "/ProjectionsEnabled", 0 );
|
||||
mMapCanvas->mapRenderer()->setProjectionsEnabled( myProjectionEnabledFlag );
|
||||
|
||||
} // QgisApp::openProject
|
||||
|
||||
|
||||
@ -3342,7 +3353,6 @@ void QgisApp::openProject( const QString & fileName )
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Open a raster or vector file; ignore other files.
|
||||
Used to process a commandline argument or OpenDocument AppleEvent.
|
||||
@ -6499,6 +6509,9 @@ void QgisApp::projectProperties()
|
||||
// changing things in the project properties dialog box
|
||||
connect( pp, SIGNAL( displayPrecisionChanged() ), this,
|
||||
SLOT( updateMouseCoordinatePrecision() ) );
|
||||
|
||||
connect( pp, SIGNAL( scalesChanged( const QStringList & ) ), mScaleEdit,
|
||||
SLOT( updateScales( const QStringList & ) ) );
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
//pass any refresh signals off to canvases
|
||||
|
@ -1440,12 +1440,12 @@ void QgsOptions::saveGdalDriverList()
|
||||
void QgsOptions::on_pbnAddScale_clicked()
|
||||
{
|
||||
int myScale = QInputDialog::getInt(
|
||||
this,
|
||||
tr( "Enter scale" ),
|
||||
tr( "Scale denominator" ),
|
||||
-1,
|
||||
1
|
||||
);
|
||||
this,
|
||||
tr( "Enter scale" ),
|
||||
tr( "Scale denominator" ),
|
||||
-1,
|
||||
1
|
||||
);
|
||||
|
||||
if ( myScale != -1 )
|
||||
{
|
||||
@ -1464,7 +1464,7 @@ void QgsOptions::on_pbnRemoveScale_clicked()
|
||||
delete itemToRemove;
|
||||
}
|
||||
|
||||
void QgsOptions::on_pbnDefaultValues_clicked()
|
||||
void QgsOptions::on_pbnDefaultScaleValues_clicked()
|
||||
{
|
||||
mListGlobalScales->clear();
|
||||
|
||||
|
@ -145,7 +145,7 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
|
||||
* used in scale combobox
|
||||
* @note added in QGIS 2.0
|
||||
*/
|
||||
void on_pbnDefaultValues_clicked();
|
||||
void on_pbnDefaultScaleValues_clicked();
|
||||
|
||||
/** Auto slot executed when the active page in the main widget stack is changed
|
||||
* @note added in 2.0
|
||||
|
@ -39,12 +39,12 @@
|
||||
|
||||
//qt includes
|
||||
#include <QColorDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QHeaderView> // Qt 4.4
|
||||
#include <QMessageBox>
|
||||
|
||||
//stdc++ includes
|
||||
|
||||
|
||||
QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *parent, Qt::WFlags fl )
|
||||
: QDialog( parent, fl )
|
||||
, mMapCanvas( mapCanvas )
|
||||
@ -113,6 +113,22 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
|
||||
myColor = QColor( myRedInt, myGreenInt, myBlueInt );
|
||||
pbnCanvasColor->setColor( myColor );
|
||||
|
||||
//get project scales
|
||||
QStringList myScales = QgsProject::instance()->readListEntry( "Scales", "/ScalesList" );
|
||||
if ( !myScales.isEmpty() )
|
||||
{
|
||||
QStringList::const_iterator scaleIt = myScales.constBegin();
|
||||
for ( ; scaleIt != myScales.constEnd(); ++scaleIt )
|
||||
{
|
||||
QListWidgetItem* newItem = new QListWidgetItem( lstScales );
|
||||
newItem->setText( *scaleIt );
|
||||
newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
|
||||
lstScales->addItem( newItem );
|
||||
}
|
||||
}
|
||||
|
||||
grpProjectScales->setChecked( QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" ) );
|
||||
|
||||
QgsMapLayer* currentLayer = 0;
|
||||
|
||||
QStringList noIdentifyLayerIdList = QgsProject::instance()->readListEntry( "Identify", "/disabledLayers" );
|
||||
@ -423,6 +439,33 @@ void QgsProjectProperties::apply()
|
||||
QgsProject::instance()->writeEntry( "Gui", "/CanvasColorGreenPart", myColor.green() );
|
||||
QgsProject::instance()->writeEntry( "Gui", "/CanvasColorBluePart", myColor.blue() );
|
||||
|
||||
//save project scales
|
||||
QStringList myScales;
|
||||
for ( int i = 0; i < lstScales->count(); ++i )
|
||||
{
|
||||
myScales.append( lstScales->item( i )->text() );
|
||||
}
|
||||
|
||||
if ( !myScales.isEmpty() )
|
||||
{
|
||||
QgsProject::instance()->writeEntry( "Scales", "/ScalesList", myScales );
|
||||
QgsProject::instance()->writeEntry( "Scales", "/useProjectScales", grpProjectScales->isChecked() );
|
||||
}
|
||||
else
|
||||
{
|
||||
QgsProject::instance()->removeEntry( "Scales", "/" );
|
||||
}
|
||||
|
||||
//use global or project scales depending on checkbox state
|
||||
if ( grpProjectScales->isChecked() )
|
||||
{
|
||||
emit scalesChanged( myScales );
|
||||
}
|
||||
else
|
||||
{
|
||||
emit scalesChanged();
|
||||
}
|
||||
|
||||
QStringList noIdentifyLayerList;
|
||||
for ( int i = 0; i < twIdentifyLayers->rowCount(); i++ )
|
||||
{
|
||||
@ -695,6 +738,33 @@ void QgsProjectProperties::on_pbnWMSSetUsedSRS_clicked()
|
||||
mWMSList->addItems( crsList.values() );
|
||||
}
|
||||
|
||||
void QgsProjectProperties::on_pbnAddScale_clicked()
|
||||
{
|
||||
int myScale = QInputDialog::getInt(
|
||||
this,
|
||||
tr( "Enter scale" ),
|
||||
tr( "Scale denominator" ),
|
||||
-1,
|
||||
1
|
||||
);
|
||||
|
||||
if ( myScale != -1 )
|
||||
{
|
||||
QListWidgetItem* newItem = new QListWidgetItem( lstScales );
|
||||
newItem->setText( QString( "1:%1" ).arg( myScale ) );
|
||||
newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
|
||||
lstScales->addItem( newItem );
|
||||
lstScales->setCurrentItem( newItem );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsProjectProperties::on_pbnRemoveScale_clicked()
|
||||
{
|
||||
int currentRow = lstScales->currentRow();
|
||||
QListWidgetItem* itemToRemove = lstScales->takeItem( currentRow );
|
||||
delete itemToRemove;
|
||||
}
|
||||
|
||||
void QgsProjectProperties::populateStyles()
|
||||
{
|
||||
// Styles - taken from qgsstylev2managerdialog
|
||||
|
@ -83,6 +83,18 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
|
||||
*/
|
||||
void on_pbnCanvasColor_clicked();
|
||||
|
||||
/*! Let the user add a scale to the list of project scales
|
||||
* used in scale combobox instead of global ones
|
||||
* @note added in QGIS 2.0
|
||||
*/
|
||||
void on_pbnAddScale_clicked();
|
||||
|
||||
/*! Let the user remove a scale from the list of project scales
|
||||
* used in scale combobox instead of global ones
|
||||
* @note added in QGIS 2.0
|
||||
*/
|
||||
void on_pbnRemoveScale_clicked();
|
||||
|
||||
/*!
|
||||
* Slots for WMS project settings
|
||||
*/
|
||||
@ -117,6 +129,9 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
|
||||
//! Signal used to inform listeners that the mouse display precision may have changed
|
||||
void displayPrecisionChanged();
|
||||
|
||||
//! Signal used to inform listeners that project scale list may have chnaged
|
||||
void scalesChanged( const QStringList &scales = QStringList() );
|
||||
|
||||
//! let listening canvases know to refresh
|
||||
void refresh();
|
||||
|
||||
|
@ -46,15 +46,15 @@ void QgsScaleComboBox::updateScales( const QStringList &scales )
|
||||
if ( !myScales.isEmpty() )
|
||||
{
|
||||
myScalesList = myScales.split( "," );
|
||||
//~ QStringList::const_iterator scaleIt = myScalesList.constBegin();
|
||||
//~ for ( ; scaleIt != myScalesList.constEnd(); ++scaleIt )
|
||||
//~ {
|
||||
//~ addItem( *scaleIt );
|
||||
//~ }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList::const_iterator scaleIt = scales.constBegin();
|
||||
for ( ; scaleIt != scales.constEnd(); ++scaleIt )
|
||||
{
|
||||
myScalesList.append( *scaleIt );
|
||||
}
|
||||
}
|
||||
|
||||
blockSignals( true );
|
||||
|
@ -858,7 +858,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>760</width>
|
||||
<width>630</width>
|
||||
<height>625</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -1104,7 +1104,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-308</y>
|
||||
<y>-313</y>
|
||||
<width>762</width>
|
||||
<height>750</height>
|
||||
</rect>
|
||||
@ -1394,7 +1394,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbnDefaultValues">
|
||||
<widget class="QToolButton" name="pbnDefaultScaleValues">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
@ -1475,8 +1475,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>778</width>
|
||||
<height>437</height>
|
||||
<width>270</width>
|
||||
<height>93</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
@ -1556,7 +1556,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>762</width>
|
||||
<width>571</width>
|
||||
<height>627</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -1932,8 +1932,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>778</width>
|
||||
<height>437</height>
|
||||
<width>425</width>
|
||||
<height>417</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_15">
|
||||
@ -2106,8 +2106,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>762</width>
|
||||
<height>566</height>
|
||||
<width>519</width>
|
||||
<height>584</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_17">
|
||||
@ -2203,7 +2203,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>762</width>
|
||||
<width>355</width>
|
||||
<height>554</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>604</width>
|
||||
<height>456</height>
|
||||
<height>588</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -295,6 +295,69 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="grpProjectScales">
|
||||
<property name="title">
|
||||
<string>Project scales</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="QListWidget" name="lstScales"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbnAddScale">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mActionNewAttribute.png</normaloff>:/images/themes/default/mActionNewAttribute.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbnRemoveScale">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mActionDeleteAttribute.png</normaloff>:/images/themes/default/mActionDeleteAttribute.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbnImportScales">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mActionFolder.png</normaloff>:/images/themes/default/mActionFolder.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbnExportScales">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mActionFileSave.png</normaloff>:/images/themes/default/mActionFileSave.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab2">
|
||||
@ -694,8 +757,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>705</width>
|
||||
<height>781</height>
|
||||
<width>637</width>
|
||||
<height>808</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
|
Loading…
x
Reference in New Issue
Block a user