Skip to content

Commit 2f1b71f

Browse files
author
g_j_m
committedJan 6, 2006

File tree

2 files changed

+343
-277
lines changed

2 files changed

+343
-277
lines changed
 

‎plugins/gps_importer/qgsgpsdevicedialog.cpp

Lines changed: 63 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ QgsGPSDeviceDialog::QgsGPSDeviceDialog(std::map<QString, QgsGPSDevice*>&
2424

2525
{
2626
setupUi(this);
27+
// Manually set the relative size of the two main parts of the
28+
// device dialog box.
29+
QList<int> split;
30+
split.append(120);
31+
split.append(340);
32+
splitter->setSizes(split);
33+
2734
QObject::connect(lbDeviceList, SIGNAL(itemSelectionChanged()),
2835
this, SLOT(slotSelectionChanged()));
2936
slotUpdateDeviceList();
@@ -51,30 +58,38 @@ void QgsGPSDeviceDialog::on_pbnDeleteDevice_clicked() {
5158

5259
std::map<QString, QgsGPSDevice*>::iterator iter =
5360
mDevices.find(lbDeviceList->currentItem()->text());
54-
delete iter->second;
55-
mDevices.erase(iter);
56-
writeDeviceSettings();
57-
slotUpdateDeviceList();
58-
emit devicesChanged();
61+
if (iter != mDevices.end())
62+
{
63+
delete iter->second;
64+
mDevices.erase(iter);
65+
writeDeviceSettings();
66+
slotUpdateDeviceList();
67+
emit devicesChanged();
68+
}
5969
}
6070
}
6171

6272

6373
void QgsGPSDeviceDialog::on_pbnUpdateDevice_clicked() {
64-
std::map<QString, QgsGPSDevice*>::iterator iter =
65-
mDevices.find(lbDeviceList->currentItem()->text());
66-
delete iter->second;
67-
mDevices.erase(iter);
68-
mDevices[leDeviceName->text()] =
69-
new QgsGPSDevice(leWptDown->text(), leWptUp->text(),
70-
leRteDown->text(), leRteUp->text(),
71-
leTrkDown->text(), leTrkUp->text());
72-
writeDeviceSettings();
73-
slotUpdateDeviceList(leDeviceName->text());
74-
emit devicesChanged();
74+
if (lbDeviceList->count() > 0)
75+
{
76+
std::map<QString, QgsGPSDevice*>::iterator iter =
77+
mDevices.find(lbDeviceList->currentItem()->text());
78+
if (iter != mDevices.end())
79+
{
80+
delete iter->second;
81+
mDevices.erase(iter);
82+
mDevices[leDeviceName->text()] =
83+
new QgsGPSDevice(leWptDown->text(), leWptUp->text(),
84+
leRteDown->text(), leRteUp->text(),
85+
leTrkDown->text(), leTrkUp->text());
86+
writeDeviceSettings();
87+
slotUpdateDeviceList(leDeviceName->text());
88+
emit devicesChanged();
89+
}
90+
}
7591
}
7692

77-
7893
void QgsGPSDeviceDialog::slotUpdateDeviceList(const QString& selection) {
7994
QString selected;
8095
if (selection == "") {
@@ -84,6 +99,12 @@ void QgsGPSDeviceDialog::slotUpdateDeviceList(const QString& selection) {
8499
else {
85100
selected = selection;
86101
}
102+
103+
// We're going to be changing the selected item, so disable our
104+
// notificaton of that.
105+
QObject::disconnect(lbDeviceList, SIGNAL(itemSelectionChanged()),
106+
this, SLOT(slotSelectionChanged()));
107+
87108
lbDeviceList->clear();
88109
std::map<QString, QgsGPSDevice*>::const_iterator iter;
89110
for (iter = mDevices.begin(); iter != mDevices.end(); ++iter) {
@@ -92,29 +113,36 @@ void QgsGPSDeviceDialog::slotUpdateDeviceList(const QString& selection) {
92113
lbDeviceList->setCurrentItem(item);
93114
}
94115
}
95-
if (lbDeviceList->currentItem() == NULL)
116+
117+
if (lbDeviceList->currentItem() == NULL && lbDeviceList->count() > 0)
96118
lbDeviceList->setCurrentRow(0);
119+
120+
// Update the display and reconnect the selection changed signal
121+
slotSelectionChanged();
122+
QObject::connect(lbDeviceList, SIGNAL(itemSelectionChanged()),
123+
this, SLOT(slotSelectionChanged()));
97124
}
98125

99126

100127
void QgsGPSDeviceDialog::slotSelectionChanged() {
101-
QString devName = lbDeviceList->currentItem()->text();
102-
103-
leDeviceName->setText(devName);
104-
QgsGPSDevice* device = mDevices[devName];
105-
106-
leWptDown->setText(device->
107-
importCommand("%babel", "-w", "%in", "%out").join(" "));
108-
leWptUp->setText(device->
109-
exportCommand("%babel", "-w", "%in", "%out").join(" "));
110-
leRteDown->setText(device->
111-
importCommand("%babel", "-r", "%in", "%out").join(" "));
112-
leRteUp->setText(device->
113-
exportCommand("%babel", "-r", "%in", "%out").join(" "));
114-
leTrkDown->setText(device->
115-
importCommand("%babel", "-t", "%in", "%out").join(" "));
116-
leTrkUp->setText(device->
117-
exportCommand("%babel", "-t", "%in", "%out").join(" "));
128+
if (lbDeviceList->count() > 0)
129+
{
130+
QString devName = lbDeviceList->currentItem()->text();
131+
leDeviceName->setText(devName);
132+
QgsGPSDevice* device = mDevices[devName];
133+
leWptDown->setText(device->
134+
importCommand("%babel", "-w", "%in", "%out").join(" "));
135+
leWptUp->setText(device->
136+
exportCommand("%babel", "-w", "%in", "%out").join(" "));
137+
leRteDown->setText(device->
138+
importCommand("%babel", "-r", "%in", "%out").join(" "));
139+
leRteUp->setText(device->
140+
exportCommand("%babel", "-r", "%in", "%out").join(" "));
141+
leTrkDown->setText(device->
142+
importCommand("%babel", "-t", "%in", "%out").join(" "));
143+
leTrkUp->setText(device->
144+
exportCommand("%babel", "-t", "%in", "%out").join(" "));
145+
}
118146
}
119147

120148

‎plugins/gps_importer/qgsgpsdevicedialogbase.ui

Lines changed: 280 additions & 242 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<rect>
99
<x>0</x>
1010
<y>0</y>
11-
<width>515</width>
12-
<height>435</height>
11+
<width>504</width>
12+
<height>436</height>
1313
</rect>
1414
</property>
1515
<property name="sizePolicy" >
@@ -26,250 +26,288 @@
2626
<property name="modal" >
2727
<bool>true</bool>
2828
</property>
29-
<widget class="QTextEdit" name="textEdit" >
30-
<property name="geometry" >
31-
<rect>
32-
<x>175</x>
33-
<y>298</y>
34-
<width>331</width>
35-
<height>91</height>
36-
</rect>
29+
<layout class="QVBoxLayout" >
30+
<property name="margin" >
31+
<number>9</number>
3732
</property>
38-
<property name="html" >
39-
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:Sans Serif; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">In the download and upload commands there can be special words that will be replaced by QGIS when the commands are used. These words are:&lt;span style=" font-style:italic;">%babel&lt;/span> - the path to GPSBabel&lt;br />&lt;span style=" font-style:italic;">%in&lt;/span> - the GPX filename when uploading or the port when downloading&lt;br />&lt;span style=" font-style:italic;">%out&lt;/span> - the port when uploading or the GPX filename when downloading&lt;/p>&lt;/body>&lt;/html></string>
33+
<property name="spacing" >
34+
<number>6</number>
4035
</property>
41-
</widget>
42-
<widget class="Line" name="line2" >
43-
<property name="geometry" >
44-
<rect>
45-
<x>160</x>
46-
<y>10</y>
47-
<width>16</width>
48-
<height>380</height>
49-
</rect>
50-
</property>
51-
<property name="frameShape" >
52-
<enum>QFrame::VLine</enum>
53-
</property>
54-
<property name="frameShadow" >
55-
<enum>QFrame::Sunken</enum>
56-
</property>
57-
<property name="orientation" >
58-
<enum>Qt::Vertical</enum>
59-
</property>
60-
</widget>
61-
<widget class="QPushButton" name="pbnUpdateDevice" >
62-
<property name="geometry" >
63-
<rect>
64-
<x>9</x>
65-
<y>358</y>
66-
<width>151</width>
67-
<height>31</height>
68-
</rect>
69-
</property>
70-
<property name="text" >
71-
<string>Update device</string>
72-
</property>
73-
</widget>
74-
<widget class="QPushButton" name="pbnDeleteDevice" >
75-
<property name="geometry" >
76-
<rect>
77-
<x>9</x>
78-
<y>321</y>
79-
<width>151</width>
80-
<height>31</height>
81-
</rect>
82-
</property>
83-
<property name="text" >
84-
<string>Delete device</string>
85-
</property>
86-
</widget>
87-
<widget class="QPushButton" name="pbnNewDevice" >
88-
<property name="geometry" >
89-
<rect>
90-
<x>9</x>
91-
<y>284</y>
92-
<width>151</width>
93-
<height>31</height>
94-
</rect>
95-
</property>
96-
<property name="text" >
97-
<string>New device</string>
98-
</property>
99-
</widget>
100-
<widget class="QPushButton" name="pbnClose" >
101-
<property name="geometry" >
102-
<rect>
103-
<x>421</x>
104-
<y>395</y>
105-
<width>85</width>
106-
<height>31</height>
107-
</rect>
108-
</property>
109-
<property name="text" >
110-
<string>Close</string>
111-
</property>
112-
<property name="default" >
113-
<bool>true</bool>
114-
</property>
115-
</widget>
116-
<widget class="QGroupBox" name="groupBox" >
117-
<property name="geometry" >
118-
<rect>
119-
<x>175</x>
120-
<y>44</y>
121-
<width>331</width>
122-
<height>247</height>
123-
</rect>
124-
</property>
125-
<property name="title" >
126-
<string>Commands</string>
127-
</property>
128-
<layout class="QGridLayout" >
129-
<property name="margin" >
130-
<number>9</number>
131-
</property>
132-
<property name="spacing" >
133-
<number>6</number>
134-
</property>
135-
<item row="5" column="1" >
136-
<widget class="QLineEdit" name="leTrkUp" >
137-
<property name="toolTip" >
138-
<string>The command that is used to upload tracks to the device</string>
139-
</property>
140-
</widget>
141-
</item>
142-
<item row="5" column="0" >
143-
<widget class="QLabel" name="textLabel1_2_5_2" >
144-
<property name="text" >
145-
<string>Track upload:</string>
146-
</property>
36+
<item>
37+
<widget class="QSplitter" name="splitter" >
38+
<property name="orientation" >
39+
<enum>Qt::Horizontal</enum>
40+
</property>
41+
<widget class="QWidget" name="layoutWidget_2" >
42+
<layout class="QVBoxLayout" >
43+
<property name="margin" >
44+
<number>0</number>
45+
</property>
46+
<property name="spacing" >
47+
<number>6</number>
48+
</property>
49+
<item>
50+
<widget class="QListWidget" name="lbDeviceList" >
51+
<property name="sizePolicy" >
52+
<sizepolicy>
53+
<hsizetype>5</hsizetype>
54+
<vsizetype>5</vsizetype>
55+
<horstretch>0</horstretch>
56+
<verstretch>0</verstretch>
57+
</sizepolicy>
58+
</property>
59+
</widget>
60+
</item>
61+
<item>
62+
<widget class="QPushButton" name="pbnNewDevice" >
63+
<property name="sizePolicy" >
64+
<sizepolicy>
65+
<hsizetype>1</hsizetype>
66+
<vsizetype>0</vsizetype>
67+
<horstretch>0</horstretch>
68+
<verstretch>0</verstretch>
69+
</sizepolicy>
70+
</property>
71+
<property name="text" >
72+
<string>New device</string>
73+
</property>
74+
</widget>
75+
</item>
76+
<item>
77+
<widget class="QPushButton" name="pbnDeleteDevice" >
78+
<property name="sizePolicy" >
79+
<sizepolicy>
80+
<hsizetype>1</hsizetype>
81+
<vsizetype>0</vsizetype>
82+
<horstretch>0</horstretch>
83+
<verstretch>0</verstretch>
84+
</sizepolicy>
85+
</property>
86+
<property name="text" >
87+
<string>Delete device</string>
88+
</property>
89+
</widget>
90+
</item>
91+
<item>
92+
<widget class="QPushButton" name="pbnUpdateDevice" >
93+
<property name="sizePolicy" >
94+
<sizepolicy>
95+
<hsizetype>1</hsizetype>
96+
<vsizetype>0</vsizetype>
97+
<horstretch>0</horstretch>
98+
<verstretch>0</verstretch>
99+
</sizepolicy>
100+
</property>
101+
<property name="text" >
102+
<string>Update device</string>
103+
</property>
104+
</widget>
105+
</item>
106+
</layout>
147107
</widget>
148-
</item>
149-
<item row="4" column="1" >
150-
<widget class="QLineEdit" name="leTrkDown" >
151-
<property name="toolTip" >
152-
<string>The command that is used to download tracks from the device</string>
153-
</property>
108+
<widget class="QWidget" name="layoutWidget_3" >
109+
<layout class="QVBoxLayout" >
110+
<property name="margin" >
111+
<number>0</number>
112+
</property>
113+
<property name="spacing" >
114+
<number>6</number>
115+
</property>
116+
<item>
117+
<layout class="QHBoxLayout" >
118+
<property name="margin" >
119+
<number>0</number>
120+
</property>
121+
<property name="spacing" >
122+
<number>6</number>
123+
</property>
124+
<item>
125+
<widget class="QLabel" name="textLabel3" >
126+
<property name="sizePolicy" >
127+
<sizepolicy>
128+
<hsizetype>1</hsizetype>
129+
<vsizetype>5</vsizetype>
130+
<horstretch>0</horstretch>
131+
<verstretch>0</verstretch>
132+
</sizepolicy>
133+
</property>
134+
<property name="text" >
135+
<string>Device name:</string>
136+
</property>
137+
</widget>
138+
</item>
139+
<item>
140+
<widget class="QLineEdit" name="leDeviceName" >
141+
<property name="sizePolicy" >
142+
<sizepolicy>
143+
<hsizetype>7</hsizetype>
144+
<vsizetype>0</vsizetype>
145+
<horstretch>2</horstretch>
146+
<verstretch>0</verstretch>
147+
</sizepolicy>
148+
</property>
149+
<property name="toolTip" >
150+
<string>This is the name of the device as it will appear in the lists</string>
151+
</property>
152+
</widget>
153+
</item>
154+
</layout>
155+
</item>
156+
<item>
157+
<widget class="QGroupBox" name="groupBox" >
158+
<property name="title" >
159+
<string>Commands</string>
160+
</property>
161+
<property name="alignment" >
162+
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
163+
</property>
164+
<layout class="QGridLayout" >
165+
<property name="margin" >
166+
<number>9</number>
167+
</property>
168+
<property name="spacing" >
169+
<number>6</number>
170+
</property>
171+
<item row="4" column="0" >
172+
<widget class="QLabel" name="textLabel1_2_5" >
173+
<property name="text" >
174+
<string>Track download:</string>
175+
</property>
176+
</widget>
177+
</item>
178+
<item row="3" column="0" >
179+
<widget class="QLabel" name="textLabel1_2_4" >
180+
<property name="text" >
181+
<string>Route upload:</string>
182+
</property>
183+
</widget>
184+
</item>
185+
<item row="0" column="0" >
186+
<widget class="QLabel" name="textLabel1_2" >
187+
<property name="text" >
188+
<string>Waypoint download:</string>
189+
</property>
190+
</widget>
191+
</item>
192+
<item row="2" column="1" >
193+
<widget class="QLineEdit" name="leRteDown" >
194+
<property name="toolTip" >
195+
<string>The command that is used to download routes from the device</string>
196+
</property>
197+
</widget>
198+
</item>
199+
<item row="2" column="0" >
200+
<widget class="QLabel" name="textLabel1_2_3" >
201+
<property name="text" >
202+
<string>Route download:</string>
203+
</property>
204+
</widget>
205+
</item>
206+
<item row="1" column="1" >
207+
<widget class="QLineEdit" name="leWptUp" >
208+
<property name="toolTip" >
209+
<string>The command that is used to upload waypoints to the device</string>
210+
</property>
211+
</widget>
212+
</item>
213+
<item row="5" column="0" >
214+
<widget class="QLabel" name="textLabel1_2_5_2" >
215+
<property name="text" >
216+
<string>Track upload:</string>
217+
</property>
218+
</widget>
219+
</item>
220+
<item row="4" column="1" >
221+
<widget class="QLineEdit" name="leTrkDown" >
222+
<property name="toolTip" >
223+
<string>The command that is used to download tracks from the device</string>
224+
</property>
225+
</widget>
226+
</item>
227+
<item row="3" column="1" >
228+
<widget class="QLineEdit" name="leRteUp" >
229+
<property name="toolTip" >
230+
<string>The command that is used to upload routes to the device</string>
231+
</property>
232+
</widget>
233+
</item>
234+
<item row="0" column="1" >
235+
<widget class="QLineEdit" name="leWptDown" >
236+
<property name="toolTip" >
237+
<string>The command that is used to download waypoints from the device</string>
238+
</property>
239+
</widget>
240+
</item>
241+
<item row="5" column="1" >
242+
<widget class="QLineEdit" name="leTrkUp" >
243+
<property name="toolTip" >
244+
<string>The command that is used to upload tracks to the device</string>
245+
</property>
246+
</widget>
247+
</item>
248+
<item row="1" column="0" >
249+
<widget class="QLabel" name="textLabel1_2_2" >
250+
<property name="text" >
251+
<string>Waypoint upload:</string>
252+
</property>
253+
</widget>
254+
</item>
255+
</layout>
256+
</widget>
257+
</item>
258+
<item>
259+
<widget class="QTextEdit" name="textEdit" >
260+
<property name="sizePolicy" >
261+
<sizepolicy>
262+
<hsizetype>5</hsizetype>
263+
<vsizetype>5</vsizetype>
264+
<horstretch>0</horstretch>
265+
<verstretch>0</verstretch>
266+
</sizepolicy>
267+
</property>
268+
<property name="html" >
269+
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:Sans Serif; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">In the download and upload commands there can be special words that will be replaced by QGIS when the commands are used. These words are:&lt;span style=" font-style:italic;">%babel&lt;/span> - the path to GPSBabel&lt;br />&lt;span style=" font-style:italic;">%in&lt;/span> - the GPX filename when uploading or the port when downloading&lt;br />&lt;span style=" font-style:italic;">%out&lt;/span> - the port when uploading or the GPX filename when downloading&lt;/p>&lt;/body>&lt;/html></string>
270+
</property>
271+
</widget>
272+
</item>
273+
</layout>
154274
</widget>
155-
</item>
156-
<item row="4" column="0" >
157-
<widget class="QLabel" name="textLabel1_2_5" >
158-
<property name="text" >
159-
<string>Track download:</string>
160-
</property>
161-
</widget>
162-
</item>
163-
<item row="3" column="1" >
164-
<widget class="QLineEdit" name="leRteUp" >
165-
<property name="toolTip" >
166-
<string>The command that is used to upload routes to the device</string>
167-
</property>
168-
</widget>
169-
</item>
170-
<item row="3" column="0" >
171-
<widget class="QLabel" name="textLabel1_2_4" >
172-
<property name="text" >
173-
<string>Route upload:</string>
174-
</property>
175-
</widget>
176-
</item>
177-
<item row="1" column="0" >
178-
<widget class="QLabel" name="textLabel1_2_2" >
179-
<property name="text" >
180-
<string>Waypoint upload:</string>
181-
</property>
182-
</widget>
183-
</item>
184-
<item row="2" column="1" >
185-
<widget class="QLineEdit" name="leRteDown" >
186-
<property name="toolTip" >
187-
<string>The command that is used to download routes from the device</string>
188-
</property>
189-
</widget>
190-
</item>
191-
<item row="1" column="1" >
192-
<widget class="QLineEdit" name="leWptUp" >
193-
<property name="toolTip" >
194-
<string>The command that is used to upload waypoints to the device</string>
195-
</property>
196-
</widget>
197-
</item>
198-
<item row="0" column="1" >
199-
<widget class="QLineEdit" name="leWptDown" >
200-
<property name="toolTip" >
201-
<string>The command that is used to download waypoints from the device</string>
202-
</property>
203-
</widget>
204-
</item>
205-
<item row="2" column="0" >
206-
<widget class="QLabel" name="textLabel1_2_3" >
207-
<property name="text" >
208-
<string>Route download:</string>
209-
</property>
210-
</widget>
211-
</item>
212-
<item row="0" column="0" >
213-
<widget class="QLabel" name="textLabel1_2" >
214-
<property name="text" >
215-
<string>Waypoint download:</string>
216-
</property>
217-
</widget>
218-
</item>
219-
</layout>
220-
</widget>
221-
<widget class="QLabel" name="textLabel3" >
222-
<property name="geometry" >
223-
<rect>
224-
<x>180</x>
225-
<y>10</y>
226-
<width>80</width>
227-
<height>29</height>
228-
</rect>
229-
</property>
230-
<property name="sizePolicy" >
231-
<sizepolicy>
232-
<hsizetype>1</hsizetype>
233-
<vsizetype>5</vsizetype>
234-
<horstretch>0</horstretch>
235-
<verstretch>0</verstretch>
236-
</sizepolicy>
237-
</property>
238-
<property name="text" >
239-
<string>Device name:</string>
240-
</property>
241-
</widget>
242-
<widget class="QLineEdit" name="leDeviceName" >
243-
<property name="geometry" >
244-
<rect>
245-
<x>280</x>
246-
<y>10</y>
247-
<width>221</width>
248-
<height>29</height>
249-
</rect>
250-
</property>
251-
<property name="sizePolicy" >
252-
<sizepolicy>
253-
<hsizetype>7</hsizetype>
254-
<vsizetype>0</vsizetype>
255-
<horstretch>2</horstretch>
256-
<verstretch>0</verstretch>
257-
</sizepolicy>
258-
</property>
259-
<property name="toolTip" >
260-
<string>This is the name of the device as it will appear in the lists</string>
261-
</property>
262-
</widget>
263-
<widget class="QListWidget" name="lbDeviceList" >
264-
<property name="geometry" >
265-
<rect>
266-
<x>10</x>
267-
<y>20</y>
268-
<width>151</width>
269-
<height>261</height>
270-
</rect>
271-
</property>
272-
</widget>
275+
</widget>
276+
</item>
277+
<item>
278+
<layout class="QHBoxLayout" >
279+
<property name="margin" >
280+
<number>0</number>
281+
</property>
282+
<property name="spacing" >
283+
<number>6</number>
284+
</property>
285+
<item>
286+
<spacer>
287+
<property name="orientation" >
288+
<enum>Qt::Horizontal</enum>
289+
</property>
290+
<property name="sizeHint" >
291+
<size>
292+
<width>381</width>
293+
<height>21</height>
294+
</size>
295+
</property>
296+
</spacer>
297+
</item>
298+
<item>
299+
<widget class="QPushButton" name="pbnClose" >
300+
<property name="text" >
301+
<string>Close</string>
302+
</property>
303+
<property name="default" >
304+
<bool>true</bool>
305+
</property>
306+
</widget>
307+
</item>
308+
</layout>
309+
</item>
310+
</layout>
273311
</widget>
274312
<layoutdefault spacing="6" margin="11" />
275313
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>

0 commit comments

Comments
 (0)
Please sign in to comment.