951 changes: 263 additions & 688 deletions src/app/qgscustomprojectiondialog.cpp

Large diffs are not rendered by default.

65 changes: 31 additions & 34 deletions src/app/qgscustomprojectiondialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "ui_qgscustomprojectiondialogbase.h"
#include "qgscontexthelp.h"
#include "qgscoordinatereferencesystem.h"

class QDir;

Expand All @@ -34,45 +35,41 @@ class QgsCustomProjectionDialog : public QDialog, private Ui::QgsCustomProjectio
public:
QgsCustomProjectionDialog( QWidget *parent = 0, Qt::WFlags fl = 0 );
~QgsCustomProjectionDialog();
//a recursive function to make a directory and its ancestors
public slots:

public slots:
void on_pbnCalculate_clicked();
void on_pbnDelete_clicked();
//
// Database navigation controles
//
long getRecordCount();
void on_pbnFirst_clicked();
void on_pbnPrevious_clicked();
void on_pbnNext_clicked();
void on_pbnLast_clicked();
void on_pbnNew_clicked();
void on_pbnSave_clicked();
void on_pbnAdd_clicked();
void on_pbnRemove_clicked();
void on_pbnCopyCRS_clicked();
void on_leNameList_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );

void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

//
// Control population
//
/* These two methods will be deprecated
void getProjList();
void getEllipsoidList();
*/
QString getProjectionFamilyName( QString theProjectionFamilyAcronym );
QString getEllipsoidName( QString theEllipsoidAcronym );
QString getProjectionFamilyAcronym( QString theProjectionFamilyName );
QString getEllipsoidAcronym( QString theEllipsoidName );
void on_buttonBox_accepted();

private:
QString getProjFromParameters();
QString getEllipseFromParameters();

QString mCurrentRecordId;
long mCurrentRecordLong;
//the record previous to starting an insert operation
//so that we can return to it if the record insert is aborted
long mLastRecordLong;
long mRecordCountLong;

//helper functions
void populateList();
QString quotedValue( QString value );
bool deleteCRS( QString id );
bool saveCRS( QgsCoordinateReferenceSystem myParameters, QString myName, QString myId, bool newEntry );
void insertProjection( QString myProjectionAcronym );

//These two QMap store the value as it is on the database when loading
QMap <QString, QgsCoordinateReferenceSystem> existingCRSparameters;
QMap <QString, QString> existingCRSnames;

//These three vectors store the value updated with the current modifications
std::vector<QString> customCRSnames;
std::vector<QString> customCRSids;
std::vector<QgsCoordinateReferenceSystem> customCRSparameters;

//vector saving the CRS to be deleted
std::vector<QString> deletedCRSs;

//Columns in the tree widget
enum columns { QGIS_CRS_NAME_COLUMN, QGIS_CRS_ID_COLUMN, QGIS_CRS_PARAMETERS_COLUMN };
};


#endif
2 changes: 1 addition & 1 deletion src/core/qgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ bool QgsCoordinateReferenceSystem::isValid() const
return mIsValidFlag;
}

bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String )
bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String, bool save )
{
//
// Examples:
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgscoordinatereferencesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
* @param theProjString A proj4 format string
* @return bool TRUE if success else false
*/
bool createFromProj4( const QString theProjString );
bool createFromProj4( const QString theProjString, bool save=true );

/*! Set up this srs from a string definition, by default a WKT definition. Otherwise
* the string defines a authority, followed by a colon, followed by the definition.
Expand Down Expand Up @@ -444,7 +444,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
long mSRID;
//!If available the authority identifier for this srs
QString mAuthId;
//! Wehter this srs is properly defined and valid
//! Wheter this srs is properly defined and valid
bool mIsValidFlag;

//! Work out the projection units and set the appropriate local variable
Expand Down
252 changes: 114 additions & 138 deletions src/ui/qgscustomprojectiondialogbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>474</width>
<height>548</height>
<width>542</width>
<height>650</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -25,7 +25,41 @@
<string>Define</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0" colspan="2">
<item row="2" column="0" colspan="4">
<widget class="QTreeWidget" name="leNameList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
<attribute name="headerShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>ID</string>
</property>
</column>
<column>
<property name="text">
<string>Parameters</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QLabel" name="label">
<property name="text">
<string>You can define your own custom Coordinate Reference System (CRS) here. The definition must conform to the proj4 format for specifying a CRS.</string>
Expand All @@ -35,118 +69,83 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Name</string>
<item row="5" column="3">
<widget class="QPlainTextEdit" name="teParameters">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="buddy">
<cstring>leName</cstring>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>70</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="4" column="3">
<widget class="QLineEdit" name="leName"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="textLabel3_2">
<item row="4" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Parameters</string>
</property>
<property name="buddy">
<cstring>leParameters</cstring>
<string>Name:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="leParameters"/>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout">
<item>
<widget class="QToolButton" name="pbnFirst">
<property name="text">
<string>|&lt;</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mIconFirst.png</normaloff>../../images/themes/default/mIconFirst.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="pbnPrevious">
<property name="text">
<string>&lt;</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mIconPrevious.png</normaloff>../../images/themes/default/mIconPrevious.png</iconset>
</property>
</widget>
</item>
<item row="5" column="2">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<widget class="QLabel" name="lblRecordNo">
<widget class="QLabel" name="label_4">
<property name="text">
<string>1 of 1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<string>Parameters:</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="pbnNext">
<widget class="QPushButton" name="pbnCopyCRS">
<property name="text">
<string>&gt;</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mIconNext.png</normaloff>../../images/themes/default/mIconNext.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="pbnLast">
<property name="text">
<string>&gt;|</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mIconLast.png</normaloff>../../images/themes/default/mIconLast.png</iconset>
<string>Copy
existing CRS</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QToolButton" name="pbnNew">
<widget class="QPushButton" name="pbnAdd">
<property name="text">
<string>*</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mIconNew.png</normaloff>../../images/themes/default/mIconNew.png</iconset>
<string>Add new CRS</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="pbnSave">
<property name="text">
<string>S</string>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mActionFileSave.png</normaloff>../../images/themes/default/mActionFileSave.png</iconset>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</spacer>
</item>
<item>
<widget class="QToolButton" name="pbnDelete">
<widget class="QPushButton" name="pbnRemove">
<property name="text">
<string>X</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mIconDelete.png</normaloff>../../images/themes/default/mIconDelete.png</iconset>
<string>Remove</string>
</property>
</widget>
</item>
Expand All @@ -155,50 +154,54 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Test</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_2">
<item row="3" column="0">
<widget class="QLabel" name="textLabel2_2_2">
<property name="text">
<string>Use the text boxes below to test the CRS definition you are creating. Enter a coordinate where both the lat/long and the transformed result are known (for example by reading off a map). Then press the calculate button to see if the CRS definition you are creating is accurate.</string>
<string>East</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<property name="buddy">
<cstring>eastWGS84</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="textLabel3_2_2">
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Parameters</string>
<string>Use the text boxes below to test the CRS definition you are creating. Enter a coordinate where both the lat/long and the transformed result are known (for example by reading off a map). Then press the calculate button to see if the CRS definition you are creating is accurate.</string>
</property>
<property name="buddy">
<cstring>leTestParameters</cstring>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="leTestParameters"/>
</item>
<item row="2" column="1">
<item row="1" column="1">
<widget class="QLabel" name="textLabel1_3">
<property name="text">
<string>Geographic / WGS84</string>
</property>
</widget>
</item>
<item row="2" column="2">
<item row="1" column="2">
<widget class="QLabel" name="textLabel2_3">
<property name="text">
<string>Destination CRS </string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QLabel" name="textLabel2_2">
<property name="text">
<string>North</string>
Expand All @@ -208,14 +211,14 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="2" column="1">
<widget class="QLineEdit" name="northWGS84">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="2">
<item row="2" column="2">
<widget class="QLabel" name="projectedX">
<property name="enabled">
<bool>true</bool>
Expand All @@ -228,20 +231,10 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="textLabel2_2_2">
<property name="text">
<string>East</string>
</property>
<property name="buddy">
<cstring>eastWGS84</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="3" column="1">
<widget class="QLineEdit" name="eastWGS84"/>
</item>
<item row="4" column="2">
<item row="3" column="2">
<widget class="QLabel" name="projectedY">
<property name="enabled">
<bool>true</bool>
Expand All @@ -257,7 +250,7 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<item row="4" column="0" colspan="3">
<widget class="QPushButton" name="pbnCalculate">
<property name="text">
<string>Calculate</string>
Expand All @@ -267,27 +260,10 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>leName</tabstop>
<tabstop>leParameters</tabstop>
<tabstop>pbnFirst</tabstop>
<tabstop>pbnPrevious</tabstop>
<tabstop>pbnNext</tabstop>
<tabstop>pbnLast</tabstop>
<tabstop>pbnNew</tabstop>
<tabstop>pbnSave</tabstop>
<tabstop>pbnDelete</tabstop>
<tabstop>leTestParameters</tabstop>
<tabstop>northWGS84</tabstop>
<tabstop>eastWGS84</tabstop>
<tabstop>pbnCalculate</tabstop>
Expand All @@ -297,17 +273,17 @@
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<signal>rejected()</signal>
<receiver>QgsCustomProjectionDialogBase</receiver>
<slot>accept()</slot>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>436</x>
<y>522</y>
<x>270</x>
<y>590</y>
</hint>
<hint type="destinationlabel">
<x>471</x>
<y>501</y>
<x>270</x>
<y>306</y>
</hint>
</hints>
</connection>
Expand Down