Skip to content

Commit ef310c3

Browse files
author
timlinux
committed
Use button box for cross platform consistency
git-svn-id: http://svn.osgeo.org/qgis/trunk@8551 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 48f37a2 commit ef310c3

File tree

2 files changed

+141
-62
lines changed

2 files changed

+141
-62
lines changed

src/app/qgsgeomtypedialog.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@
1717
/* $Id$ */
1818

1919
#include "qgsgeomtypedialog.h"
20-
#include "qgsaddattrdialog.h"
20+
#include "qgsapplication.h"
21+
#include <QPushButton>
2122

2223
QgsGeomTypeDialog::QgsGeomTypeDialog(QWidget *parent, Qt::WFlags fl)
2324
: QDialog(parent, fl)
2425
{
2526
setupUi(this);
26-
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
27-
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
27+
QString myThemePath = QgsApplication::themePath();
28+
mAddAttributeButton->setIcon(QIcon(QPixmap(myThemePath + "/mActionNewAttribute.png")));
29+
mRemoveAttributeButton->setIcon(QIcon(QPixmap(myThemePath + "/mActionDeleteAttribute.png")));
30+
mTypeBox->addItem(tr("Real"),"Real");
31+
mTypeBox->addItem(tr("Integer"),"Integer");;
32+
mTypeBox->addItem(tr("String"),"String");
2833

2934
mPointRadioButton->setChecked(true);
3035
mFileFormatComboBox->insertItem("ESRI Shapefile");
@@ -58,19 +63,15 @@ QGis::WKBTYPE QgsGeomTypeDialog::selectedType() const
5863

5964
void QgsGeomTypeDialog::on_mAddAttributeButton_clicked()
6065
{
61-
std::list<QString> types;
62-
types.push_back("Real");
63-
types.push_back("Integer");
64-
types.push_back("String");
65-
QgsAddAttrDialog d(types, this);
66-
if(d.exec()==QDialog::Accepted)
67-
{
68-
mAttributeView->addTopLevelItem(new QTreeWidgetItem(QStringList() << d.name() << d.type()));
69-
}
66+
QString myName = mNameEdit->text();
67+
//use userrole to avoid translated type string
68+
QString myType = mTypeBox->itemData ( mTypeBox->currentIndex(),Qt::UserRole ).toString();
69+
mAttributeView->addTopLevelItem(new QTreeWidgetItem( QStringList() << myName << myType ));
7070
if(mAttributeView->topLevelItemCount()>0)
7171
{
7272
mOkButton->setEnabled(true);
7373
}
74+
mNameEdit->clear();
7475
}
7576

7677
void QgsGeomTypeDialog::on_mRemoveAttributeButton_clicked()

src/ui/qgsgeomtypedialogbase.ui

Lines changed: 128 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<rect>
66
<x>0</x>
77
<y>0</y>
8-
<width>400</width>
9-
<height>427</height>
8+
<width>395</width>
9+
<height>422</height>
1010
</rect>
1111
</property>
1212
<property name="windowTitle" >
@@ -16,7 +16,7 @@
1616
<bool>true</bool>
1717
</property>
1818
<layout class="QGridLayout" >
19-
<item row="1" column="0" colspan="2" >
19+
<item row="0" column="0" >
2020
<widget class="QLabel" name="mFileFormatLabel" >
2121
<property name="text" >
2222
<string>File format</string>
@@ -26,50 +26,10 @@
2626
</property>
2727
</widget>
2828
</item>
29-
<item row="1" column="2" colspan="2" >
29+
<item row="0" column="1" colspan="3" >
3030
<widget class="QComboBox" name="mFileFormatComboBox" />
3131
</item>
32-
<item row="3" column="1" colspan="2" >
33-
<widget class="QPushButton" name="mRemoveAttributeButton" >
34-
<property name="text" >
35-
<string>Remove</string>
36-
</property>
37-
</widget>
38-
</item>
39-
<item row="3" column="3" >
40-
<spacer>
41-
<property name="orientation" >
42-
<enum>Qt::Horizontal</enum>
43-
</property>
44-
<property name="sizeType" >
45-
<enum>QSizePolicy::Expanding</enum>
46-
</property>
47-
<property name="sizeHint" >
48-
<size>
49-
<width>91</width>
50-
<height>20</height>
51-
</size>
52-
</property>
53-
</spacer>
54-
</item>
55-
<item row="2" column="0" colspan="3" >
56-
<widget class="QLabel" name="mAttributeLabel" >
57-
<property name="text" >
58-
<string>Attributes</string>
59-
</property>
60-
<property name="buddy" >
61-
<cstring>mAddAttributeButton</cstring>
62-
</property>
63-
</widget>
64-
</item>
65-
<item row="3" column="0" >
66-
<widget class="QPushButton" name="mAddAttributeButton" >
67-
<property name="text" >
68-
<string>Add</string>
69-
</property>
70-
</widget>
71-
</item>
72-
<item row="0" column="0" colspan="4" >
32+
<item row="1" column="0" colspan="4" >
7333
<widget class="QGroupBox" name="buttonGroup1" >
7434
<property name="title" >
7535
<string>Type</string>
@@ -99,8 +59,89 @@
9959
</layout>
10060
</widget>
10161
</item>
102-
<item row="4" column="0" colspan="4" >
62+
<item row="2" column="0" colspan="4" >
63+
<widget class="QLabel" name="mAttributeLabel" >
64+
<property name="text" >
65+
<string>Attributes</string>
66+
</property>
67+
</widget>
68+
</item>
69+
<item row="3" column="0" >
70+
<widget class="QLabel" name="textLabel1" >
71+
<property name="text" >
72+
<string>Name</string>
73+
</property>
74+
<property name="buddy" >
75+
<cstring>mNameEdit</cstring>
76+
</property>
77+
</widget>
78+
</item>
79+
<item row="3" column="1" colspan="3" >
80+
<widget class="QLineEdit" name="mNameEdit" />
81+
</item>
82+
<item row="4" column="0" >
83+
<widget class="QLabel" name="textLabel2" >
84+
<property name="text" >
85+
<string>Type</string>
86+
</property>
87+
<property name="buddy" >
88+
<cstring>mTypeBox</cstring>
89+
</property>
90+
</widget>
91+
</item>
92+
<item row="4" column="1" colspan="3" >
93+
<widget class="QComboBox" name="mTypeBox" />
94+
</item>
95+
<item row="5" column="0" colspan="2" >
96+
<spacer>
97+
<property name="orientation" >
98+
<enum>Qt::Horizontal</enum>
99+
</property>
100+
<property name="sizeHint" >
101+
<size>
102+
<width>291</width>
103+
<height>20</height>
104+
</size>
105+
</property>
106+
</spacer>
107+
</item>
108+
<item row="5" column="2" >
109+
<widget class="QToolButton" name="mRemoveAttributeButton" >
110+
<property name="toolTip" >
111+
<string>Remove selected row</string>
112+
</property>
113+
<property name="text" >
114+
<string>...</string>
115+
</property>
116+
<property name="icon" >
117+
<iconset>../../images/themes/default/mActionDeleteAttribute.png</iconset>
118+
</property>
119+
</widget>
120+
</item>
121+
<item row="5" column="3" >
122+
<widget class="QToolButton" name="mAddAttributeButton" >
123+
<property name="toolTip" >
124+
<string>Add values manually</string>
125+
</property>
126+
<property name="text" >
127+
<string>...</string>
128+
</property>
129+
<property name="icon" >
130+
<iconset>../../images/themes/default/mActionNewAttribute.png</iconset>
131+
</property>
132+
</widget>
133+
</item>
134+
<item row="6" column="0" colspan="4" >
103135
<widget class="QTreeWidget" name="mAttributeView" >
136+
<property name="sizePolicy" >
137+
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
138+
<horstretch>0</horstretch>
139+
<verstretch>0</verstretch>
140+
</sizepolicy>
141+
</property>
142+
<property name="alternatingRowColors" >
143+
<bool>true</bool>
144+
</property>
104145
<property name="rootIsDecorated" >
105146
<bool>false</bool>
106147
</property>
@@ -116,7 +157,7 @@
116157
</column>
117158
</widget>
118159
</item>
119-
<item row="5" column="0" colspan="4" >
160+
<item row="7" column="0" colspan="4" >
120161
<widget class="QDialogButtonBox" name="buttonBox" >
121162
<property name="orientation" >
122163
<enum>Qt::Horizontal</enum>
@@ -130,13 +171,50 @@
130171
</widget>
131172
<layoutdefault spacing="6" margin="11" />
132173
<tabstops>
174+
<tabstop>mFileFormatComboBox</tabstop>
133175
<tabstop>mPointRadioButton</tabstop>
134176
<tabstop>mLineRadioButton</tabstop>
135177
<tabstop>mPolygonRadioButton</tabstop>
136-
<tabstop>mFileFormatComboBox</tabstop>
137-
<tabstop>mAddAttributeButton</tabstop>
178+
<tabstop>mNameEdit</tabstop>
179+
<tabstop>mTypeBox</tabstop>
138180
<tabstop>mRemoveAttributeButton</tabstop>
181+
<tabstop>mAddAttributeButton</tabstop>
182+
<tabstop>mAttributeView</tabstop>
183+
<tabstop>buttonBox</tabstop>
139184
</tabstops>
140185
<resources/>
141-
<connections/>
186+
<connections>
187+
<connection>
188+
<sender>buttonBox</sender>
189+
<signal>accepted()</signal>
190+
<receiver>QgsGeomTypeDialogBase</receiver>
191+
<slot>accept()</slot>
192+
<hints>
193+
<hint type="sourcelabel" >
194+
<x>349</x>
195+
<y>400</y>
196+
</hint>
197+
<hint type="destinationlabel" >
198+
<x>387</x>
199+
<y>304</y>
200+
</hint>
201+
</hints>
202+
</connection>
203+
<connection>
204+
<sender>buttonBox</sender>
205+
<signal>rejected()</signal>
206+
<receiver>QgsGeomTypeDialogBase</receiver>
207+
<slot>reject()</slot>
208+
<hints>
209+
<hint type="sourcelabel" >
210+
<x>275</x>
211+
<y>400</y>
212+
</hint>
213+
<hint type="destinationlabel" >
214+
<x>242</x>
215+
<y>308</y>
216+
</hint>
217+
</hints>
218+
</connection>
219+
</connections>
142220
</ui>

0 commit comments

Comments
 (0)