Skip to content

Commit cb9669e

Browse files
committedApr 17, 2023
Always show coordinates
1 parent 98bb668 commit cb9669e

File tree

3 files changed

+69
-121
lines changed

3 files changed

+69
-121
lines changed
 

‎src/app/qgsmeasuredialog.cpp

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,9 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool *tool, Qt::WindowFlags f )
5959
QPushButton *cpb = new QPushButton( tr( "Copy &All" ) );
6060
buttonBox->addButton( cpb, QDialogButtonBox::ActionRole );
6161
connect( cpb, &QAbstractButton::clicked, this, &QgsMeasureDialog::copyMeasurements );
62-
63-
// Toggle the coordinates columns visibility
64-
connect( mShowCoordinates, &QCheckBox::clicked, this, &QgsMeasureDialog::showCoordinatesChanged );
65-
showCoordinatesChanged();
6662
}
6763
else
6864
{
69-
mShowCoordinates->hide();
7065
mCopySettingsGroupBox->hide();
7166
}
7267

@@ -146,20 +141,6 @@ void QgsMeasureDialog::crsChanged()
146141
updateUi();
147142
}
148143

149-
void QgsMeasureDialog::showCoordinatesChanged()
150-
{
151-
// if Show Coordinates is unchecked, Hide the X and Y columns
152-
mTable->setColumnHidden( Columns::X, !mShowCoordinates->isChecked() );
153-
mTable->setColumnHidden( Columns::Y, !mShowCoordinates->isChecked() );
154-
155-
// The first row contains the first point, with no computed distance
156-
// so we hide it if Show Coordinates is unchecked
157-
if ( mTable->topLevelItemCount() > 0 )
158-
{
159-
mTable->topLevelItem( 0 )->setHidden( !mShowCoordinates->isChecked() );
160-
}
161-
}
162-
163144
void QgsMeasureDialog::updateSettings()
164145
{
165146
const QgsSettings settings;
@@ -289,12 +270,6 @@ void QgsMeasureDialog::addPoint()
289270
item->setText( Columns::X, QLocale().toString( lastPoint.x(), 'f', mDecimalPlacesCoordinates ) );
290271
item->setText( Columns::Y, QLocale().toString( lastPoint.y(), 'f', mDecimalPlacesCoordinates ) );
291272
mTable->addTopLevelItem( item );
292-
293-
// Hide the first item if Show Coordinates is unchecked
294-
if ( !mShowCoordinates->isChecked() )
295-
{
296-
item->setHidden( true );
297-
}
298273
}
299274
QTreeWidgetItem *item = new QTreeWidgetItem();
300275
QgsPointXY lastPoint = mTool->points().last();
@@ -663,12 +638,6 @@ void QgsMeasureDialog::updateUi()
663638
item->setText( Columns::X, QLocale().toString( p2.x(), 'f', mDecimalPlacesCoordinates ) );
664639
item->setText( Columns::Y, QLocale().toString( p2.y(), 'f', mDecimalPlacesCoordinates ) );
665640
mTable->addTopLevelItem( item );
666-
667-
// Hide the first row if the coordinates are not shown
668-
if ( !mShowCoordinates->isChecked() )
669-
{
670-
item->setHidden( true );
671-
}
672641
}
673642
else
674643
{
@@ -748,7 +717,6 @@ double QgsMeasureDialog::convertArea( double area, Qgis::AreaUnit toUnit ) const
748717

749718
void QgsMeasureDialog::copyMeasurements()
750719
{
751-
bool copyCoordinates = mShowCoordinates->isChecked();
752720
bool includeHeader = mIncludeHeader->isChecked();
753721

754722
// Get the separator
@@ -766,35 +734,25 @@ void QgsMeasureDialog::copyMeasurements()
766734
else
767735
separator = mSeparatorCustom->text();
768736

769-
770737
QClipboard *clipboard = QApplication::clipboard();
771738
QString text;
772739
QTreeWidgetItemIterator it( mTable );
773740

774741
if ( includeHeader )
775742
{
776-
if ( copyCoordinates )
777-
{
778-
text += mTable->headerItem()->text( Columns::X ) + separator;
779-
text += mTable->headerItem()->text( Columns::Y ) + separator;
780-
}
743+
text += mTable->headerItem()->text( Columns::X ) + separator;
744+
text += mTable->headerItem()->text( Columns::Y ) + separator;
781745
text += mTable->headerItem()->text( Columns::Distance ) + QStringLiteral( "\n" );
782746
}
783-
// Discard the first item if show coordinates is not checked
784-
if ( !copyCoordinates )
785-
{
786-
it++;
787-
}
747+
788748
while ( *it )
789749
{
790-
if ( copyCoordinates )
791-
{
792-
text += ( *it )->text( Columns::X ) + separator;
793-
text += ( *it )->text( Columns::Y ) + separator;
794-
}
750+
text += ( *it )->text( Columns::X ) + separator;
751+
text += ( *it )->text( Columns::Y ) + separator;
795752
text += ( *it )->text( Columns::Distance ) + QStringLiteral( "\n" );
796753
it++;
797754
}
755+
798756
clipboard->setText( text );
799757
}
800758

‎src/app/qgsmeasuredialog.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ class APP_EXPORT QgsMeasureDialog : public QDialog, private Ui::QgsMeasureBase
7373
//! Copy measurements to the clipboard
7474
void copyMeasurements();
7575

76-
void showCoordinatesChanged();
77-
7876
void crsChanged();
7977

8078
void projChanged();

‎src/ui/qgsmeasurebase.ui

Lines changed: 63 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>430</width>
10-
<height>472</height>
10+
<height>443</height>
1111
</rect>
1212
</property>
1313
<property name="baseSize">
@@ -39,6 +39,35 @@
3939
<property name="spacing">
4040
<number>6</number>
4141
</property>
42+
<item row="8" column="0" colspan="4">
43+
<widget class="QgsCollapsibleGroupBox" name="groupBox">
44+
<property name="title">
45+
<string>Info</string>
46+
</property>
47+
<layout class="QVBoxLayout" name="verticalLayout">
48+
<item>
49+
<widget class="QLabel" name="mNotesLabel">
50+
<property name="text">
51+
<string/>
52+
</property>
53+
<property name="wordWrap">
54+
<bool>true</bool>
55+
</property>
56+
</widget>
57+
</item>
58+
</layout>
59+
</widget>
60+
</item>
61+
<item row="4" column="3">
62+
<widget class="QComboBox" name="mUnitsCombo"/>
63+
</item>
64+
<item row="11" column="0" colspan="4">
65+
<widget class="QDialogButtonBox" name="buttonBox">
66+
<property name="standardButtons">
67+
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
68+
</property>
69+
</widget>
70+
</item>
4271
<item row="2" column="0" colspan="4">
4372
<widget class="QTreeWidget" name="mTable">
4473
<property name="editTriggers">
@@ -73,36 +102,7 @@
73102
</column>
74103
</widget>
75104
</item>
76-
<item row="7" column="2">
77-
<widget class="QRadioButton" name="mEllipsoidal">
78-
<property name="text">
79-
<string>Ellipsoidal</string>
80-
</property>
81-
<property name="checked">
82-
<bool>true</bool>
83-
</property>
84-
</widget>
85-
</item>
86105
<item row="9" column="0" colspan="4">
87-
<widget class="QgsCollapsibleGroupBox" name="groupBox">
88-
<property name="title">
89-
<string>Info</string>
90-
</property>
91-
<layout class="QVBoxLayout" name="verticalLayout">
92-
<item>
93-
<widget class="QLabel" name="mNotesLabel">
94-
<property name="text">
95-
<string/>
96-
</property>
97-
<property name="wordWrap">
98-
<bool>true</bool>
99-
</property>
100-
</widget>
101-
</item>
102-
</layout>
103-
</widget>
104-
</item>
105-
<item row="10" column="0" colspan="4">
106106
<spacer name="mSpacer">
107107
<property name="orientation">
108108
<enum>Qt::Vertical</enum>
@@ -115,32 +115,16 @@
115115
</property>
116116
</spacer>
117117
</item>
118-
<item row="4" column="2">
119-
<widget class="QLineEdit" name="editTotal">
120-
<property name="font">
121-
<font>
122-
<weight>75</weight>
123-
<bold>true</bold>
124-
</font>
125-
</property>
126-
<property name="alignment">
127-
<set>Qt::AlignRight</set>
128-
</property>
129-
<property name="readOnly">
130-
<bool>true</bool>
118+
<item row="7" column="0">
119+
<widget class="QRadioButton" name="mCartesian">
120+
<property name="text">
121+
<string>Cartesian</string>
131122
</property>
132-
</widget>
133-
</item>
134-
<item row="12" column="0" colspan="4">
135-
<widget class="QDialogButtonBox" name="buttonBox">
136-
<property name="standardButtons">
137-
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
123+
<property name="checked">
124+
<bool>false</bool>
138125
</property>
139126
</widget>
140127
</item>
141-
<item row="4" column="3">
142-
<widget class="QComboBox" name="mUnitsCombo"/>
143-
</item>
144128
<item row="4" column="1">
145129
<spacer>
146130
<property name="orientation">
@@ -157,6 +141,16 @@
157141
</property>
158142
</spacer>
159143
</item>
144+
<item row="4" column="0">
145+
<widget class="QLabel" name="totalDistanceLabel">
146+
<property name="text">
147+
<string>Total</string>
148+
</property>
149+
<property name="buddy">
150+
<cstring>editTotal</cstring>
151+
</property>
152+
</widget>
153+
</item>
160154
<item row="6" column="0">
161155
<widget class="QLabel" name="totalHorizontalDistanceLabel">
162156
<property name="text">
@@ -180,27 +174,33 @@
180174
</property>
181175
</widget>
182176
</item>
183-
<item row="4" column="0">
184-
<widget class="QLabel" name="totalDistanceLabel">
185-
<property name="text">
186-
<string>Total</string>
177+
<item row="4" column="2">
178+
<widget class="QLineEdit" name="editTotal">
179+
<property name="font">
180+
<font>
181+
<weight>75</weight>
182+
<bold>true</bold>
183+
</font>
187184
</property>
188-
<property name="buddy">
189-
<cstring>editTotal</cstring>
185+
<property name="alignment">
186+
<set>Qt::AlignRight</set>
187+
</property>
188+
<property name="readOnly">
189+
<bool>true</bool>
190190
</property>
191191
</widget>
192192
</item>
193-
<item row="7" column="0">
194-
<widget class="QRadioButton" name="mCartesian">
193+
<item row="7" column="2">
194+
<widget class="QRadioButton" name="mEllipsoidal">
195195
<property name="text">
196-
<string>Cartesian</string>
196+
<string>Ellipsoidal</string>
197197
</property>
198198
<property name="checked">
199-
<bool>false</bool>
199+
<bool>true</bool>
200200
</property>
201201
</widget>
202202
</item>
203-
<item row="11" column="0" colspan="4">
203+
<item row="10" column="0" colspan="4">
204204
<widget class="QgsCollapsibleGroupBox" name="mCopySettingsGroupBox">
205205
<property name="title">
206206
<string>Copy settings</string>
@@ -299,13 +299,6 @@
299299
</layout>
300300
</widget>
301301
</item>
302-
<item row="8" column="0" colspan="4">
303-
<widget class="QCheckBox" name="mShowCoordinates">
304-
<property name="text">
305-
<string>Show coordinates</string>
306-
</property>
307-
</widget>
308-
</item>
309302
</layout>
310303
</widget>
311304
<layoutdefault spacing="6" margin="11"/>
@@ -324,7 +317,6 @@
324317
<tabstop>mUnitsCombo</tabstop>
325318
<tabstop>editHorizontalTotal</tabstop>
326319
<tabstop>mCartesian</tabstop>
327-
<tabstop>mShowCoordinates</tabstop>
328320
<tabstop>mIncludeHeader</tabstop>
329321
<tabstop>mSeparatorComma</tabstop>
330322
<tabstop>mSeparatorSemicolon</tabstop>

0 commit comments

Comments
 (0)
Please sign in to comment.