Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
missed a dialog
  • Loading branch information
jef-n committed May 13, 2012
1 parent 2130b02 commit 4b5d265
Show file tree
Hide file tree
Showing 3 changed files with 217 additions and 0 deletions.
74 changes: 74 additions & 0 deletions src/providers/wms/qgswmtsdimensions.cpp
@@ -0,0 +1,74 @@
/***************************************************************************
qgswmtsdimensions.cpp - selector for WMTS dimensions
-------------------
begin : 2. May 2012
copyright : (C) 2012 Juergen E. Fischer < jef at norbit dot de >, norBIT GmbH
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgswmsprovider.h"
#include "qgswmtsdimensions.h"

#include <QSettings>
#include <QComboBox>

QgsWmtsDimensions::QgsWmtsDimensions( const QgsWmtsTileLayer &layer, QWidget *parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
setupUi( this );

QStringList dims = layer.dimensions.keys();
qSort( dims );

mDimensions->setRowCount( dims.size() );

for( int i = 0; i < mDimensions->rowCount(); i++ )
{
const QgsWmtsDimension &d = layer.dimensions[ dims[i] ];

mDimensions->setItem( i, 0, new QTableWidgetItem( d.identifier ) );
mDimensions->setItem( i, 1, new QTableWidgetItem( d.title ) );
mDimensions->setItem( i, 2, new QTableWidgetItem( d.abstract ) );
mDimensions->setItem( i, 3, new QTableWidgetItem( d.defaultValue ) );

QComboBox *cb = new QComboBox( mDimensions );
cb->addItems( d.values );
int idx = cb->findText( d.defaultValue );
cb->setCurrentIndex( idx < 0 ? 0 : idx );
mDimensions->setCellWidget( i, 4, cb );

i++;
}

QSettings settings;
QgsDebugMsg( "restoring geometry" );
restoreGeometry( settings.value( "/Windows/WMTSDimensions/geometry" ).toByteArray() );
}

QgsWmtsDimensions::~QgsWmtsDimensions()
{
QSettings settings;
QgsDebugMsg( "saving geometry" );
settings.setValue( "/Windows/WmtsDimensions/geometry", saveGeometry() );
}

void QgsWmtsDimensions::selectedDimensions( QHash<QString, QString> &selected )
{
selected.clear();

for( int i = 0; i<mDimensions->rowCount(); i++ )
{
QComboBox *cb = qobject_cast< QComboBox * >( mDimensions->cellWidget( i, 4 ) );
Q_ASSERT( cb );
selected.insert( mDimensions->item( i, 0 )->text(), cb->currentText() );
}
}
50 changes: 50 additions & 0 deletions src/providers/wms/qgswmtsdimensions.h
@@ -0,0 +1,50 @@
/***************************************************************************
qgswmtsdimensions.h - selector for WMTS dimensions
-------------------
begin : 2. May 2012
copyright : (C) 2012 by Jürgen Fischer, norBIT GmbH
email: : jef (at) norbit (dot) de
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSWMTSDIMENSIONS_H
#define QGSWMTSDIMENSIONS_H
#include "ui_qgswmtsdimensionsbase.h"
#include "qgisgui.h"
#include "qgscontexthelp.h"
#include "qgswmsprovider.h"

#include <QHash>

/*!
* \brief Dialog to select dimension values for WMTS layers
*
* This dialog allows the user to select dimensions values the
* WMTS offers.
*
*/
class QgsWmtsDimensions : public QDialog, private Ui::QgsWmtsDimensionsBase
{
Q_OBJECT

public:
//! Constructor
QgsWmtsDimensions( const QgsWmtsTileLayer &layer, QWidget *parent = 0, Qt::WFlags fl = 0 );
//! Destructor
~QgsWmtsDimensions();

void selectedDimensions( QHash<QString, QString> &dims );

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


#endif // QGSWMTSDIMENSIONS_H
93 changes: 93 additions & 0 deletions src/ui/qgswmtsdimensionsbase.ui
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsWmtsDimensionsBase</class>
<widget class="QDialog" name="QgsWmtsDimensionsBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>767</width>
<height>315</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTableWidget" name="mDimensions">
<column>
<property name="text">
<string>Dimension</string>
</property>
</column>
<column>
<property name="text">
<string>Value</string>
</property>
</column>
<column>
<property name="text">
<string>Abstract</string>
</property>
</column>
<column>
<property name="text">
<string>Default</string>
</property>
</column>
<column>
<property name="text">
<string>Value</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QgsWmtsDimensionsBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QgsWmtsDimensionsBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0 comments on commit 4b5d265

Please sign in to comment.