Skip to content
Permalink
Browse files

started datum UI refactoring

  • Loading branch information
3nids authored and nyalldawson committed Nov 23, 2017
1 parent 3916628 commit f4eae2888a7fc8f7cb261570dcb3a7cf4bf85fa9
@@ -22,6 +22,7 @@ SET(QGIS_APP_SRCS
qgsclipboard.cpp
qgscustomization.cpp
qgscustomprojectiondialog.cpp
qgsdatumtransformtablemodel.cpp
qgsdecorationitem.cpp
qgsdecorationcopyright.cpp
qgsdecorationcopyrightdialog.cpp
@@ -246,6 +247,7 @@ SET (QGIS_APP_MOC_HDRS
qgsclipboard.h
qgscustomization.h
qgscustomprojectiondialog.h
qgsdatumtransformtablemodel.h
qgsdecorationitem.h
qgsdecorationcopyright.h
qgsdecorationcopyrightdialog.h
@@ -0,0 +1,58 @@
#include "qgsdatumtransformtablemodel.h"

QgsDatumTransformTableModel::QgsDatumTransformTableModel(QObject *parent)
: QAbstractTableModel(parent)
{
}

void QgsDatumTransformTableModel::setTransformContext(QgsCoordinateTransformContext &context)
{
mTransformContext = context;
reset();
}

int QgsDatumTransformTableModel::rowCount(const QModelIndex &parent) const
{
return mTransformContext.sourceDestinationDatumTransforms().count()
+ mTransformContext.sourceDatumTransforms().count()
+ mTransformContext.destinationDatumTransforms().count();
}

int QgsDatumTransformTableModel::columnCount(const QModelIndex &parent) const
{
return 4;
}

QVariant QgsDatumTransformTableModel::data(const QModelIndex &index, int role) const
{


return QVariant();
}

QVariant QgsDatumTransformTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Vertical)
return QVariant();

switch (role) {
case Qt::DisplayRole:
switch (section) {
case SourceCrsHeader:
return tr("Source CRS");
case SourceTransformHeader:
return tr("Source datum transform");
case DestinationCrsHeader:
return tr("Destination CRS");
case DestinationTransformHeader:
return tr("Destination datum transform");
default:
break;
}
break;
default:
break;
}

return QVariant();
}
@@ -0,0 +1,36 @@
#ifndef QGSDATUMTRANSFORMTABLEMODEL_H
#define QGSDATUMTRANSFORMTABLEMODEL_H


#include <QAbstractTableModel>

#include "qgis_app.h"
#include "qgscoordinatetransformcontext.h"

class APP_EXPORT QgsDatumTransformTableModel : public QAbstractTableModel
{
Q_OBJECT
public:

enum Headers {
SourceCrsHeader = 0,
SourceTransformHeader,
DestinationCrsHeader,
DestinationTransformHeader,
};

QgsDatumTransformTableModel( QObject* parent = nullptr);

void setTransformContext( QgsCoordinateTransformContext &context );

public:
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;

private:
QgsCoordinateTransformContext mTransformContext;
};

#endif // QGSDATUMTRANSFORMTABLEMODEL_H
@@ -24,6 +24,7 @@
#include "qgisapp.h"
#include "qgscomposer.h"
#include "qgscoordinatetransform.h"
#include "qgsdatumtransformtablemodel.h"
#include "qgslayoutmanager.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
@@ -154,6 +155,17 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
updateGuiForMapUnits( QgsProject::instance()->crs().mapUnits() );
projectionSelector->setCrs( QgsProject::instance()->crs() );

// Datum transforms
QgsDatumTransformTableModel* datumTransformTableModel = new QgsDatumTransformTableModel(this);
QgsCoordinateTransformContext context = QgsProject::instance()->transformContext();
datumTransformTableModel->setTransformContext(context);
mDatumTransformTableView->setModel(datumTransformTableModel);
mDatumTransformTableView->resizeColumnToContents( 0 );
mDatumTransformTableView->horizontalHeader()->show();
mDatumTransformTableView->setSelectionMode( QAbstractItemView::SingleSelection );
mDatumTransformTableView->setSelectionBehavior( QAbstractItemView::SelectRows );
connect(mDatumTransformAddButton, &QToolButton::clicked, this, &QgsProjectProperties::addDatumTransform);

QPolygonF mainCanvasPoly = mapCanvas->mapSettings().visiblePolygon();
QgsGeometry g = QgsGeometry::fromQPolygonF( mainCanvasPoly );
// close polygon
@@ -1212,7 +1224,12 @@ void QgsProjectProperties::apply()

void QgsProjectProperties::showProjectionsTab()
{
mOptionsListWidget->setCurrentRow( 1 );
mOptionsListWidget->setCurrentRow( 1 );
}

QgsProjectProperties::addDatumTransform()
{

}

void QgsProjectProperties::cbxWFSPubliedStateChanged( int aIdx )
@@ -69,6 +69,9 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
*/
void showProjectionsTab();

//! add a new datum transform
addDatumTransform();

/**
* Let the user add a scale to the list of project scales
* used in scale combobox instead of global ones */
@@ -266,6 +266,6 @@ void QgsDatumTransformDialog::accepted()

void QgsDatumTransformDialog::updateTitle()
{
mLabelSrcCrs->setText( QStringLiteral( "%1 - %2" ).arg( mSrcCrs.authid(), mSrcCrs.isValid() ? mSrcCrs.description() : tr( "unknown" ) ) );
mLabelDstCrs->setText( QStringLiteral( "%1 - %2" ).arg( mDestCrs.authid(), mDestCrs.isValid() ? mDestCrs.description() : tr( "unknown" ) ) );
mSourceCrsButton->setText( QStringLiteral( "%1 - %2" ).arg( mSrcCrs.authid(), mSrcCrs.isValid() ? mSrcCrs.description() : tr( "unknown" ) ) );
mDstCrsButton->setText( QStringLiteral( "%1 - %2" ).arg( mDestCrs.authid(), mDestCrs.isValid() ? mDestCrs.description() : tr( "unknown" ) ) );
}
@@ -14,59 +14,15 @@
<string>Select Datum Transformations</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<widget class="QLabel" name="mLabelSrcDescription">
<property name="text">
<string notr="true">Description</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="mRememberSelectionCheckBox">
<property name="text">
<string>Remember selection</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="mHideDeprecatedCheckBox">
<property name="text">
<string>Hide deprecated</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Destination CRS</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="mLabelDstDescription">
<item row="3" column="0">
<widget class="QLabel" name="mLabelSrcDescription">
<property name="text">
<string notr="true">Description</string>
</property>
@@ -86,16 +42,16 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="mLabelSrcCrs">
<widget class="QPushButton" name="mSourceCrsButton">
<property name="text">
<string notr="true">Source CRS</string>
<string>source CRS</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="mLabelDstCrs">
<widget class="QPushButton" name="mDstCrsButton">
<property name="text">
<string notr="true">Destination CRS</string>
<string>destination CRS</string>
</property>
</widget>
</item>
@@ -118,6 +74,50 @@
</column>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="mLabelDstDescription">
<property name="text">
<string notr="true">Description</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="mRememberSelectionCheckBox">
<property name="text">
<string>Remember selection</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="mHideDeprecatedCheckBox">
<property name="text">
<string>Hide deprecated</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">

0 comments on commit f4eae28

Please sign in to comment.
You can’t perform that action at this time.