Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use button box for cross platform consistency
git-svn-id: http://svn.osgeo.org/qgis/trunk@8551 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed May 30, 2008
1 parent 48f37a2 commit ef310c3
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 62 deletions.
25 changes: 13 additions & 12 deletions src/app/qgsgeomtypedialog.cpp
Expand Up @@ -17,14 +17,19 @@
/* $Id$ */

#include "qgsgeomtypedialog.h"
#include "qgsaddattrdialog.h"
#include "qgsapplication.h"
#include <QPushButton>

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

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

void QgsGeomTypeDialog::on_mAddAttributeButton_clicked()
{
std::list<QString> types;
types.push_back("Real");
types.push_back("Integer");
types.push_back("String");
QgsAddAttrDialog d(types, this);
if(d.exec()==QDialog::Accepted)
{
mAttributeView->addTopLevelItem(new QTreeWidgetItem(QStringList() << d.name() << d.type()));
}
QString myName = mNameEdit->text();
//use userrole to avoid translated type string
QString myType = mTypeBox->itemData ( mTypeBox->currentIndex(),Qt::UserRole ).toString();
mAttributeView->addTopLevelItem(new QTreeWidgetItem( QStringList() << myName << myType ));
if(mAttributeView->topLevelItemCount()>0)
{
mOkButton->setEnabled(true);
}
mNameEdit->clear();
}

void QgsGeomTypeDialog::on_mRemoveAttributeButton_clicked()
Expand Down
178 changes: 128 additions & 50 deletions src/ui/qgsgeomtypedialogbase.ui
Expand Up @@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>427</height>
<width>395</width>
<height>422</height>
</rect>
</property>
<property name="windowTitle" >
Expand All @@ -16,7 +16,7 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<item row="1" column="0" colspan="2" >
<item row="0" column="0" >
<widget class="QLabel" name="mFileFormatLabel" >
<property name="text" >
<string>File format</string>
Expand All @@ -26,50 +26,10 @@
</property>
</widget>
</item>
<item row="1" column="2" colspan="2" >
<item row="0" column="1" colspan="3" >
<widget class="QComboBox" name="mFileFormatComboBox" />
</item>
<item row="3" column="1" colspan="2" >
<widget class="QPushButton" name="mRemoveAttributeButton" >
<property name="text" >
<string>Remove</string>
</property>
</widget>
</item>
<item row="3" column="3" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>91</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="3" >
<widget class="QLabel" name="mAttributeLabel" >
<property name="text" >
<string>Attributes</string>
</property>
<property name="buddy" >
<cstring>mAddAttributeButton</cstring>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QPushButton" name="mAddAttributeButton" >
<property name="text" >
<string>Add</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4" >
<item row="1" column="0" colspan="4" >
<widget class="QGroupBox" name="buttonGroup1" >
<property name="title" >
<string>Type</string>
Expand Down Expand Up @@ -99,8 +59,89 @@
</layout>
</widget>
</item>
<item row="4" column="0" colspan="4" >
<item row="2" column="0" colspan="4" >
<widget class="QLabel" name="mAttributeLabel" >
<property name="text" >
<string>Attributes</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<string>Name</string>
</property>
<property name="buddy" >
<cstring>mNameEdit</cstring>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3" >
<widget class="QLineEdit" name="mNameEdit" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
<string>Type</string>
</property>
<property name="buddy" >
<cstring>mTypeBox</cstring>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3" >
<widget class="QComboBox" name="mTypeBox" />
</item>
<item row="5" column="0" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>291</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="2" >
<widget class="QToolButton" name="mRemoveAttributeButton" >
<property name="toolTip" >
<string>Remove selected row</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionDeleteAttribute.png</iconset>
</property>
</widget>
</item>
<item row="5" column="3" >
<widget class="QToolButton" name="mAddAttributeButton" >
<property name="toolTip" >
<string>Add values manually</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionNewAttribute.png</iconset>
</property>
</widget>
</item>
<item row="6" column="0" colspan="4" >
<widget class="QTreeWidget" name="mAttributeView" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alternatingRowColors" >
<bool>true</bool>
</property>
<property name="rootIsDecorated" >
<bool>false</bool>
</property>
Expand All @@ -116,7 +157,7 @@
</column>
</widget>
</item>
<item row="5" column="0" colspan="4" >
<item row="7" column="0" colspan="4" >
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
Expand All @@ -130,13 +171,50 @@
</widget>
<layoutdefault spacing="6" margin="11" />
<tabstops>
<tabstop>mFileFormatComboBox</tabstop>
<tabstop>mPointRadioButton</tabstop>
<tabstop>mLineRadioButton</tabstop>
<tabstop>mPolygonRadioButton</tabstop>
<tabstop>mFileFormatComboBox</tabstop>
<tabstop>mAddAttributeButton</tabstop>
<tabstop>mNameEdit</tabstop>
<tabstop>mTypeBox</tabstop>
<tabstop>mRemoveAttributeButton</tabstop>
<tabstop>mAddAttributeButton</tabstop>
<tabstop>mAttributeView</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QgsGeomTypeDialogBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>349</x>
<y>400</y>
</hint>
<hint type="destinationlabel" >
<x>387</x>
<y>304</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QgsGeomTypeDialogBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>275</x>
<y>400</y>
</hint>
<hint type="destinationlabel" >
<x>242</x>
<y>308</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0 comments on commit ef310c3

Please sign in to comment.