~ubuntu-branches/ubuntu/quantal/qgis/quantal

« back to all changes in this revision

Viewing changes to src/gui/qgsgeomtypedialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): William Grant
  • Date: 2007-05-06 13:42:32 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070506134232-pyli6t388w5asd8x
Tags: 0.8.0-3ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - debian/rules, debian/qgis.install, debian/qgis.dirs debian/qgis.desktop:
    Add and install .desktop.
* debian/qgis.desktop: Remove Applications category; it's not real.
* Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                         qgsgeomtypedialog.cpp  -  description
 
3
                             -------------------
 
4
    begin                : October 2004
 
5
    copyright            : (C) 2004 by Marco Hugentobler
 
6
    email                : marco.hugentobler@autoform.ch
 
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
/* $Id: qgsgeomtypedialog.cpp 4695 2006-01-15 21:22:13Z gsherman $ */
 
18
 
 
19
#include "qgsgeomtypedialog.h"
 
20
#include "qgsaddattrdialog.h"
 
21
 
 
22
QgsGeomTypeDialog::QgsGeomTypeDialog(): QDialog()
 
23
{
 
24
    setupUi(this);
 
25
    connect(mOkButton, SIGNAL(clicked()), this, SLOT(accept()));
 
26
    connect(mCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
 
27
 
 
28
    mPointRadioButton->setChecked(true);
 
29
    mAttributeView->removeColumn(0);
 
30
    mAttributeView->addColumn(tr("Name"));
 
31
    mAttributeView->addColumn(tr("Type"));
 
32
    mFileFormatComboBox->insertItem("ESRI Shapefile");
 
33
    /*mFileFormatComboBox->insertItem("Comma Separated Value");
 
34
    mFileFormatComboBox->insertItem("GML");
 
35
    mFileFormatComboBox->insertItem("Mapinfo File");*/
 
36
}
 
37
 
 
38
QgsGeomTypeDialog::~QgsGeomTypeDialog()
 
39
{
 
40
 
 
41
}
 
42
 
 
43
QGis::WKBTYPE QgsGeomTypeDialog::selectedType() const
 
44
{
 
45
    if(mPointRadioButton->isChecked())
 
46
    {
 
47
        return QGis::WKBPoint;
 
48
    }
 
49
    else if(mLineRadioButton->isChecked())
 
50
    {
 
51
        return QGis::WKBLineString;
 
52
    }
 
53
    else if(mPolygonRadioButton->isChecked())
 
54
    {
 
55
        return QGis::WKBPolygon;
 
56
    }
 
57
 
 
58
    return QGis::WKBUnknown;
 
59
}
 
60
 
 
61
void QgsGeomTypeDialog::on_mAddAttributeButton_clicked()
 
62
{
 
63
    std::list<QString> types;
 
64
    types.push_back("Real");
 
65
    types.push_back("Integer");
 
66
    types.push_back("String");
 
67
    QgsAddAttrDialog d(types);
 
68
    if(d.exec()==QDialog::Accepted)
 
69
    {
 
70
        Q3ListViewItem* attritem=new Q3ListViewItem(mAttributeView, d.name(), d.type());
 
71
    }
 
72
    if(mAttributeView->childCount()>0)
 
73
    {
 
74
        mOkButton->setEnabled(true);
 
75
    }
 
76
}
 
77
 
 
78
void QgsGeomTypeDialog::on_mRemoveAttributeButton_clicked()
 
79
{
 
80
    delete(mAttributeView->currentItem());
 
81
    if(mAttributeView->childCount()==0)
 
82
    {
 
83
        mOkButton->setEnabled(false);   
 
84
    }
 
85
    
 
86
}
 
87
 
 
88
void QgsGeomTypeDialog::on_btnHelp_clicked()
 
89
{
 
90
  QgsContextHelp::run(context_id);
 
91
}
 
92
void QgsGeomTypeDialog::attributes(std::list<std::pair<QString, QString> >& at) const
 
93
{
 
94
    Q3ListViewItemIterator it(mAttributeView);
 
95
    while ( it.current() ) 
 
96
    {
 
97
        Q3ListViewItem *item = it.current();
 
98
        at.push_back(std::make_pair(item->text(0), item->text(1)));
 
99
#ifdef QGISDEBUG
 
100
        qWarning(("appending "+item->text(0)+"//"+item->text(1)).toLocal8Bit().data());
 
101
#endif  
 
102
        ++it;
 
103
    }
 
104
}
 
105
 
 
106
QString QgsGeomTypeDialog::selectedFileFormat() const
 
107
{
 
108
    return mFileFormatComboBox->currentText();
 
109
}