gistfile1.diff
src/app/qgisapp.cpp | ||
---|---|---|
2797 | 2797 |
myRenderer->setProjectionsEnabled( settings.value( "/Projections/otfTransformEnabled", 0 ).toBool() ); |
2798 | 2798 | |
2799 | 2799 |
updateCRSStatusBar(); |
2800 |
|
|
2801 |
// update the scale list combobox |
|
2802 |
QStringList projectScaleList; |
|
2803 |
projectScaleList = prj->readListEntry( "ProjectScaleList", "/" ); |
|
2804 |
mScaleEdit->updateScales( projectScaleList ); |
|
2800 | 2805 | |
2801 | 2806 |
// set the initial map tool |
2802 | 2807 |
mMapCanvas->setMapTool( mMapTools.mPan ); |
... | ... | |
2914 | 2919 |
emit projectRead(); // let plug-ins know that we've read in a new |
2915 | 2920 |
// project so that they can check any project |
2916 | 2921 |
// specific plug-in state |
2922 |
|
|
2923 |
// update the scale list combobox |
|
2924 |
QStringList projectScaleList; |
|
2925 |
double currentScale = mMapCanvas->scale(); |
|
2926 |
projectScaleList = QgsProject::instance()->readListEntry( "ProjectScaleList", "/" ); |
|
2927 |
mScaleEdit->updateScales( projectScaleList ); |
|
2928 |
showScale( currentScale ); |
|
2917 | 2929 | |
2918 | 2930 |
// add this to the list of recently used project files |
2919 | 2931 |
saveRecentProjectPath( fullPath, settings ); |
... | ... | |
2983 | 2995 | |
2984 | 2996 |
// add this to the list of recently used project files |
2985 | 2997 |
saveRecentProjectPath( projectFile, settings ); |
2998 |
|
|
2999 |
// update the scale list combobox |
|
3000 |
QStringList projectScaleList; |
|
3001 |
double currentScale = mMapCanvas->scale(); |
|
3002 |
projectScaleList = QgsProject::instance()->readListEntry( "ProjectScaleList", "/" ); |
|
3003 |
mScaleEdit->updateScales( projectScaleList ); |
|
3004 |
showScale( currentScale ); |
|
2986 | 3005 | |
2987 | 3006 |
QApplication::restoreOverrideCursor(); |
2988 | 3007 | |
... | ... | |
6245 | 6264 |
// Line below was commented out by wonder three years ago (r4949). |
6246 | 6265 |
// It is needed to refresh scale bar after changing display units. |
6247 | 6266 |
connect( pp, SIGNAL( refresh() ), mMapCanvas, SLOT( refresh() ) ); |
6248 | ||
6267 |
|
|
6268 |
// pass projectScalesChanged signal |
|
6269 |
// to QgsScaleComboBox |
|
6270 |
connect( pp, SIGNAL( projectScalesChanged( QStringList ) ), |
|
6271 |
mScaleEdit, SLOT( updateScales( QStringList ) ) ); |
|
6272 |
|
|
6249 | 6273 |
QgsMapRenderer* myRender = mMapCanvas->mapRenderer(); |
6250 | 6274 |
bool wasProjected = myRender->hasCrsTransformEnabled(); |
6251 | 6275 |
long oldCRSID = myRender->destinationCrs().srsid(); |
src/app/qgsprojectproperties.cpp | ||
---|---|---|
276 | 276 |
twWFSLayers->setRowCount( j ); |
277 | 277 |
twWFSLayers->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents ); |
278 | 278 | |
279 |
// Project Scales List |
|
280 |
QStringList projectScaleList; |
|
281 |
projectScaleList = QgsProject::instance()->readListEntry( "ProjectScaleList", "/" ); |
|
282 |
grpProjectScaleList->setChecked( projectScaleList.size() > 0 ); |
|
283 |
if ( grpProjectScaleList->isChecked() ) |
|
284 |
{ |
|
285 |
mProjectScaleList->addItems( projectScaleList ); |
|
286 |
} |
|
287 |
grpProjectScaleList->setChecked( mProjectScaleList->count() > 0 ); |
|
288 | ||
279 | 289 |
restoreState(); |
280 | 290 |
} |
281 | 291 | |
... | ... | |
505 | 515 |
} |
506 | 516 |
} |
507 | 517 |
QgsProject::instance()->writeEntry( "WFSLayers", "/", wfsLayerList ); |
518 |
|
|
519 |
|
|
520 |
// Project Scales List write |
|
521 |
QString initProjectScaleList; |
|
522 |
initProjectScaleList = QgsProject::instance()->readListEntry( "ProjectScaleList", "/" ).join(","); |
|
523 |
QStringList projectScaleList; |
|
524 |
if ( grpProjectScaleList->isChecked() && mProjectScaleList->count() == 0 ) |
|
525 |
{ |
|
526 |
QMessageBox::information( this, |
|
527 |
tr( "Project Scales List" ), |
|
528 |
tr( "No scale for this project. Disabling scale restriction." ) ); |
|
529 |
grpProjectScaleList->setChecked( false ); |
|
530 |
} |
|
531 |
QgsProject::instance()->removeEntry( "ProjectScaleList", "/" ); |
|
508 | 532 | |
533 |
if ( grpProjectScaleList->isChecked() ) |
|
534 |
{ |
|
535 |
for ( int i = 0; i < mProjectScaleList->count(); i++ ) |
|
536 |
{ |
|
537 |
projectScaleList << mProjectScaleList->item( i )->text(); |
|
538 |
} |
|
539 |
QgsProject::instance()->writeEntry( "ProjectScaleList", "/", projectScaleList ); |
|
540 |
} |
|
541 |
else |
|
542 |
{ |
|
543 |
projectScaleList.clear(); |
|
544 |
QgsProject::instance()->removeEntry( "ProjectScaleList", "/" ); |
|
545 |
} |
|
546 |
if ( initProjectScaleList != projectScaleList.join(",") ) |
|
547 |
{ |
|
548 |
emit projectScalesChanged( projectScaleList ); |
|
549 |
mMapCanvas->updateScale(); |
|
550 |
} |
|
551 |
|
|
509 | 552 |
//todo XXX set canvas color |
510 | 553 |
emit refresh(); |
511 | 554 |
} |
... | ... | |
677 | 720 |
mWMSList->clear(); |
678 | 721 |
mWMSList->addItems( crsList.values() ); |
679 | 722 |
} |
723 | ||
724 |
// Project Scale List add/remove |
|
725 |
void QgsProjectProperties::on_pbnScaleListRemoveScale_clicked() |
|
726 |
{ |
|
727 |
foreach( QListWidgetItem *item, mProjectScaleList->selectedItems() ) |
|
728 |
{ |
|
729 |
delete item; |
|
730 |
} |
|
731 |
} |
|
732 | ||
733 |
bool stringSortAsInt( const QString &s1, const QString &s2 ) |
|
734 |
{ |
|
735 |
return( s1.toInt() > s2.toInt() ); |
|
736 |
} |
|
737 | ||
738 |
void QgsProjectProperties::on_pbnScaleListAddScale_clicked() |
|
739 |
{ |
|
740 |
QString newScale = mProjectScaleInput->text(); |
|
741 |
bool scOk = true; |
|
742 |
if ( newScale.isEmpty() ) |
|
743 |
{ |
|
744 |
QMessageBox::information( this, |
|
745 |
tr( "Project Scale Addition" ), |
|
746 |
tr( "Scale cannot be empty" ) ); |
|
747 |
scOk = false; |
|
748 |
} |
|
749 |
else |
|
750 |
{ |
|
751 |
int newScaleInt = newScale.toInt(&scOk); |
|
752 |
if (!scOk) |
|
753 |
{ |
|
754 |
QMessageBox::information( this, |
|
755 |
tr( "Project Scale Addition" ), |
|
756 |
tr( "Scale must be an integer" ) ); |
|
757 |
mProjectScaleInput->setText( QString("") ); |
|
758 |
} |
|
759 |
} |
|
760 |
if( scOk ) |
|
761 |
{ |
|
762 |
QStringList projectScaleList; |
|
763 |
for ( int i = 0; i < mProjectScaleList->count(); i++ ) |
|
764 |
{ |
|
765 |
projectScaleList << mProjectScaleList->item( i )->text(); |
|
766 |
if( newScale == mProjectScaleList->item( i )->text() ) |
|
767 |
{ |
|
768 |
scOk = false; |
|
769 |
} |
|
770 |
} |
|
771 |
if (scOk) |
|
772 |
{ |
|
773 |
projectScaleList << newScale; |
|
774 |
qSort(projectScaleList.begin(), projectScaleList.end(), stringSortAsInt); |
|
775 |
mProjectScaleList->clear(); |
|
776 |
mProjectScaleList->addItems( projectScaleList ); |
|
777 |
mProjectScaleInput->setText( QString("") ); |
|
778 |
} |
|
779 |
else |
|
780 |
{ |
|
781 |
QMessageBox::information( this, |
|
782 |
tr( "Project Scale Addition" ), |
|
783 |
tr( "Scale is already in the list" ) ); |
|
784 |
} |
|
785 |
} |
|
786 | ||
787 |
} |
src/app/qgsprojectproperties.h | ||
---|---|---|
90 | 90 |
void on_pbnWMSAddSRS_clicked(); |
91 | 91 |
void on_pbnWMSRemoveSRS_clicked(); |
92 | 92 |
void on_pbnWMSSetUsedSRS_clicked(); |
93 |
|
|
94 |
/*! |
|
95 |
* Slots for project scales settings |
|
96 |
*/ |
|
97 |
void on_pbnScaleListRemoveScale_clicked(); |
|
98 |
void on_pbnScaleListAddScale_clicked(); |
|
93 | 99 | |
94 | 100 |
/*! |
95 | 101 |
* Slot to show the context help for this dialog |
... | ... | |
107 | 113 |
//! Signal used to inform listeners that the mouse display precision may have changed |
108 | 114 |
void displayPrecisionChanged(); |
109 | 115 | |
116 |
/** Signal emitted when the user defined scales change */ |
|
117 |
void projectScalesChanged( QStringList ); |
|
118 | ||
110 | 119 |
//! let listening canvases know to refresh |
111 | 120 |
void refresh(); |
112 | 121 |
src/gui/qgsscalecombobox.cpp | ||
---|---|---|
18 | 18 |
#include "qgsscalecombobox.h" |
19 | 19 | |
20 | 20 |
#include <QAbstractItemView> |
21 |
#include <QSettings> |
|
22 | ||
21 | 23 | |
22 | 24 |
QgsScaleComboBox::QgsScaleComboBox( QWidget* parent ) : QComboBox( parent ) |
23 | 25 |
{ |
24 | 26 |
// make combobox editable and populate with predefined scales |
25 | 27 |
setEditable( true ); |
26 |
addItem( "1:1000000" ); |
|
27 |
addItem( "1:500000" ); |
|
28 |
addItem( "1:250000" ); |
|
29 |
addItem( "1:100000" ); |
|
30 |
addItem( "1:50000" ); |
|
31 |
addItem( "1:25000" ); |
|
32 |
addItem( "1:10000" ); |
|
33 |
addItem( "1:5000" ); |
|
34 |
addItem( "1:2500" ); |
|
35 |
addItem( "1:1000" ); |
|
36 |
addItem( "1:500" ); |
|
37 | ||
28 |
QStringList defaultScaleList; |
|
29 |
updateScales( defaultScaleList ); |
|
38 | 30 |
setInsertPolicy( QComboBox::NoInsert ); |
39 | 31 |
} |
40 | 32 | |
... | ... | |
68 | 60 |
view()->setCurrentIndex( model()->index( idx, 0 ) ); |
69 | 61 |
blockSignals( false ); |
70 | 62 |
} |
63 | ||
64 | ||
65 |
void QgsScaleComboBox::updateScales( QStringList list) |
|
66 |
{ |
|
67 |
// If list is empty, load default list |
|
68 |
if ( list.isEmpty() ) |
|
69 |
{ |
|
70 |
list << "1:1000000" << "1:500000" << "1:250000" << "1:100000" << "1:50000" ; |
|
71 |
list << "1:25000" << "1:10000" << "1:5000" << "1:2500" << "1:1000" << "1:500" ; |
|
72 |
} |
|
73 |
else |
|
74 |
{ |
|
75 |
// Need to add "1:" before each scale taken from project configuration |
|
76 |
list.replaceInStrings(QRegExp("^(.*)$"), "1:\\1"); |
|
77 |
} |
|
78 |
// populate the list |
|
79 |
blockSignals( true ); |
|
80 |
clear(); |
|
81 |
addItems( list ); |
|
82 |
blockSignals( false ); |
|
83 |
} |
src/gui/qgsscalecombobox.h | ||
---|---|---|
30 | 30 |
public: |
31 | 31 |
QgsScaleComboBox( QWidget* parent = 0 ); |
32 | 32 |
virtual ~QgsScaleComboBox(); |
33 |
|
|
34 |
public slots: |
|
35 |
void updateScales( QStringList ); |
|
33 | 36 | |
34 | 37 |
protected: |
35 | 38 |
void showPopup(); |
39 | ||
36 | 40 |
}; |
37 | 41 | |
38 | 42 |
#endif // QGSSCALECOMBOBOX_H |
src/ui/qgsprojectpropertiesbase.ui | ||
---|---|---|
190 | 190 |
</item> |
191 | 191 |
</layout> |
192 | 192 |
</widget> |
193 |
</item> |
|
193 |
</item>
|
|
194 | 194 |
<item row="1" column="0"> |
195 | 195 |
<widget class="QGroupBox" name="btnGrpMapUnits"> |
196 | 196 |
<property name="title"> |
... | ... | |
295 | 295 |
</layout> |
296 | 296 |
</widget> |
297 | 297 |
</item> |
298 |
<item row="3" column="0"> |
|
299 |
<widget class="QGroupBox" name="grpProjectScaleList"> |
|
300 |
<property name="title"> |
|
301 |
<string>Project Scales</string> |
|
302 |
</property> |
|
303 |
<property name="checkable"> |
|
304 |
<bool>true</bool> |
|
305 |
</property> |
|
306 |
<property name="checked"> |
|
307 |
<bool>false</bool> |
|
308 |
</property> |
|
309 |
<layout class="QGridLayout" name="gridLayout_9"> |
|
310 |
<item row="0" column="0" colspan="3"> |
|
311 |
<widget class="QListWidget" name="mProjectScaleList"/> |
|
312 |
</item> |
|
313 |
<item row="1" column="0"> |
|
314 |
<widget class="QLineEdit" name="mProjectScaleInput"/> |
|
315 |
</item> |
|
316 |
<item row="1" column="1"> |
|
317 |
<widget class="QPushButton" name="pbnScaleListAddScale"> |
|
318 |
<property name="text"> |
|
319 |
<string>Add</string> |
|
320 |
</property> |
|
321 |
</widget> |
|
322 |
</item> |
|
323 |
<item row="1" column="2"> |
|
324 |
<widget class="QPushButton" name="pbnScaleListRemoveScale"> |
|
325 |
<property name="text"> |
|
326 |
<string>Remove</string> |
|
327 |
</property> |
|
328 |
</widget> |
|
329 |
</item> |
|
330 |
</layout> |
|
331 |
</widget> |
|
332 |
</item> |
|
298 | 333 |
</layout> |
299 | 334 |
</widget> |
300 | 335 |
<widget class="QWidget" name="tab2"> |
... | ... | |
329 | 364 |
<widget class="QgsProjectionSelector" name="projectionSelector" native="true"/> |
330 | 365 |
</item> |
331 | 366 |
</layout> |
332 |
</widget> |
|
367 |
</widget>
|
|
333 | 368 |
<widget class="QWidget" name="tab3"> |
334 | 369 |
<attribute name="icon"> |
335 | 370 |
<iconset resource="../../images/images.qrc"> |
... | ... | |
743 | 778 |
<tabstop>pbnWMSAddSRS</tabstop> |
744 | 779 |
<tabstop>pbnWMSSetUsedSRS</tabstop> |
745 | 780 |
<tabstop>pbnWMSRemoveSRS</tabstop> |
781 |
<tabstop>mProjectScaleInput</tabstop> |
|
782 |
<tabstop>pbnScaleListRemoveScale</tabstop> |
|
783 |
<tabstop>pbnScaleListAddScale</tabstop> |
|
746 | 784 |
</tabstops> |
747 | 785 |
<resources> |
748 | 786 |
<include location="../../images/images.qrc"/> |