Skip to content

Commit 4b5d265

Browse files
committed
missed a dialog
1 parent 2130b02 commit 4b5d265

File tree

3 files changed

+217
-0
lines changed

3 files changed

+217
-0
lines changed
+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/***************************************************************************
2+
qgswmtsdimensions.cpp - selector for WMTS dimensions
3+
-------------------
4+
begin : 2. May 2012
5+
copyright : (C) 2012 Juergen E. Fischer < jef at norbit dot de >, norBIT GmbH
6+
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#include "qgswmsprovider.h"
19+
#include "qgswmtsdimensions.h"
20+
21+
#include <QSettings>
22+
#include <QComboBox>
23+
24+
QgsWmtsDimensions::QgsWmtsDimensions( const QgsWmtsTileLayer &layer, QWidget *parent, Qt::WFlags fl )
25+
: QDialog( parent, fl )
26+
{
27+
setupUi( this );
28+
29+
QStringList dims = layer.dimensions.keys();
30+
qSort( dims );
31+
32+
mDimensions->setRowCount( dims.size() );
33+
34+
for( int i = 0; i < mDimensions->rowCount(); i++ )
35+
{
36+
const QgsWmtsDimension &d = layer.dimensions[ dims[i] ];
37+
38+
mDimensions->setItem( i, 0, new QTableWidgetItem( d.identifier ) );
39+
mDimensions->setItem( i, 1, new QTableWidgetItem( d.title ) );
40+
mDimensions->setItem( i, 2, new QTableWidgetItem( d.abstract ) );
41+
mDimensions->setItem( i, 3, new QTableWidgetItem( d.defaultValue ) );
42+
43+
QComboBox *cb = new QComboBox( mDimensions );
44+
cb->addItems( d.values );
45+
int idx = cb->findText( d.defaultValue );
46+
cb->setCurrentIndex( idx < 0 ? 0 : idx );
47+
mDimensions->setCellWidget( i, 4, cb );
48+
49+
i++;
50+
}
51+
52+
QSettings settings;
53+
QgsDebugMsg( "restoring geometry" );
54+
restoreGeometry( settings.value( "/Windows/WMTSDimensions/geometry" ).toByteArray() );
55+
}
56+
57+
QgsWmtsDimensions::~QgsWmtsDimensions()
58+
{
59+
QSettings settings;
60+
QgsDebugMsg( "saving geometry" );
61+
settings.setValue( "/Windows/WmtsDimensions/geometry", saveGeometry() );
62+
}
63+
64+
void QgsWmtsDimensions::selectedDimensions( QHash<QString, QString> &selected )
65+
{
66+
selected.clear();
67+
68+
for( int i = 0; i<mDimensions->rowCount(); i++ )
69+
{
70+
QComboBox *cb = qobject_cast< QComboBox * >( mDimensions->cellWidget( i, 4 ) );
71+
Q_ASSERT( cb );
72+
selected.insert( mDimensions->item( i, 0 )->text(), cb->currentText() );
73+
}
74+
}

src/providers/wms/qgswmtsdimensions.h

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/***************************************************************************
2+
qgswmtsdimensions.h - selector for WMTS dimensions
3+
-------------------
4+
begin : 2. May 2012
5+
copyright : (C) 2012 by Jürgen Fischer, norBIT GmbH
6+
email: : jef (at) norbit (dot) de
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#ifndef QGSWMTSDIMENSIONS_H
19+
#define QGSWMTSDIMENSIONS_H
20+
#include "ui_qgswmtsdimensionsbase.h"
21+
#include "qgisgui.h"
22+
#include "qgscontexthelp.h"
23+
#include "qgswmsprovider.h"
24+
25+
#include <QHash>
26+
27+
/*!
28+
* \brief Dialog to select dimension values for WMTS layers
29+
*
30+
* This dialog allows the user to select dimensions values the
31+
* WMTS offers.
32+
*
33+
*/
34+
class QgsWmtsDimensions : public QDialog, private Ui::QgsWmtsDimensionsBase
35+
{
36+
Q_OBJECT
37+
38+
public:
39+
//! Constructor
40+
QgsWmtsDimensions( const QgsWmtsTileLayer &layer, QWidget *parent = 0, Qt::WFlags fl = 0 );
41+
//! Destructor
42+
~QgsWmtsDimensions();
43+
44+
void selectedDimensions( QHash<QString, QString> &dims );
45+
46+
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
47+
};
48+
49+
50+
#endif // QGSWMTSDIMENSIONS_H

src/ui/qgswmtsdimensionsbase.ui

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>QgsWmtsDimensionsBase</class>
4+
<widget class="QDialog" name="QgsWmtsDimensionsBase">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>767</width>
10+
<height>315</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Dialog</string>
15+
</property>
16+
<layout class="QGridLayout" name="gridLayout">
17+
<item row="0" column="0">
18+
<widget class="QTableWidget" name="mDimensions">
19+
<column>
20+
<property name="text">
21+
<string>Dimension</string>
22+
</property>
23+
</column>
24+
<column>
25+
<property name="text">
26+
<string>Value</string>
27+
</property>
28+
</column>
29+
<column>
30+
<property name="text">
31+
<string>Abstract</string>
32+
</property>
33+
</column>
34+
<column>
35+
<property name="text">
36+
<string>Default</string>
37+
</property>
38+
</column>
39+
<column>
40+
<property name="text">
41+
<string>Value</string>
42+
</property>
43+
</column>
44+
</widget>
45+
</item>
46+
<item row="1" column="0">
47+
<widget class="QDialogButtonBox" name="buttonBox">
48+
<property name="orientation">
49+
<enum>Qt::Horizontal</enum>
50+
</property>
51+
<property name="standardButtons">
52+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
53+
</property>
54+
</widget>
55+
</item>
56+
</layout>
57+
</widget>
58+
<resources/>
59+
<connections>
60+
<connection>
61+
<sender>buttonBox</sender>
62+
<signal>accepted()</signal>
63+
<receiver>QgsWmtsDimensionsBase</receiver>
64+
<slot>accept()</slot>
65+
<hints>
66+
<hint type="sourcelabel">
67+
<x>248</x>
68+
<y>254</y>
69+
</hint>
70+
<hint type="destinationlabel">
71+
<x>157</x>
72+
<y>274</y>
73+
</hint>
74+
</hints>
75+
</connection>
76+
<connection>
77+
<sender>buttonBox</sender>
78+
<signal>rejected()</signal>
79+
<receiver>QgsWmtsDimensionsBase</receiver>
80+
<slot>reject()</slot>
81+
<hints>
82+
<hint type="sourcelabel">
83+
<x>316</x>
84+
<y>260</y>
85+
</hint>
86+
<hint type="destinationlabel">
87+
<x>286</x>
88+
<y>274</y>
89+
</hint>
90+
</hints>
91+
</connection>
92+
</connections>
93+
</ui>

0 commit comments

Comments
 (0)