~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/plugins/evis/databaseconnection/evisdatabaselayerfieldselectiongui.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
** File: evisdatabaselayerfieldselectiongui.cpp
 
3
** Author: Peter J. Ersts ( ersts at amnh.org )
 
4
** Creation Date: 2007-03-07
 
5
**
 
6
** Copyright ( c ) 2007, American Museum of Natural History. All rights reserved.
 
7
**
 
8
** This library/program is free software; you can redistribute it
 
9
** and/or modify it under the terms of the GNU Library General Public
 
10
** License as published by the Free Software Foundation; either
 
11
** version 2 of the License, or ( at your option ) any later version.
 
12
**
 
13
** This library/program is distributed in the hope that it will be useful,
 
14
** but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
** Library General Public License for more details.
 
17
**
 
18
** This work was made possible through a grant by the the John D. and
 
19
** Catherine T. MacArthur Foundation. Additionally, this program was prepared by
 
20
** the American Museum of Natural History under award No. NA05SEC46391002
 
21
** from the National Oceanic and Atmospheric Administration, U.S. Department
 
22
** of Commerce.  The statements, findings, conclusions, and recommendations
 
23
** are those of the author( s ) and do not necessarily reflect the views of the
 
24
** National Oceanic and Atmospheric Administration or the Department of Commerce.
 
25
**
 
26
**/
 
27
/*  $Id: $ */
 
28
#include "evisdatabaselayerfieldselectiongui.h"
 
29
 
 
30
/**
 
31
* Constructor
 
32
* @param parent - Pointer the to parent QWidget for modality
 
33
* @param fl - Windown flags
 
34
*/
 
35
eVisDatabaseLayerFieldSelectionGui::eVisDatabaseLayerFieldSelectionGui( QWidget* parent, Qt::WFlags fl )
 
36
    : QDialog( parent, fl )
 
37
{
 
38
  setupUi( this );
 
39
}
 
40
 
 
41
/**
 
42
* Public method that will insert the values in fieldList into the x and y coordinate selection combo boxes.
 
43
* @param fileList - QStringList containing the field names to add to the combo boxes
 
44
*/
 
45
void eVisDatabaseLayerFieldSelectionGui::setFieldList( QStringList* fieldList )
 
46
{
 
47
 
 
48
  int xCoordinateIndex = -1;
 
49
  int yCoordinateIndex = -1;
 
50
  cboxXCoordinate->clear( );
 
51
  cboxYCoordinate->clear( );
 
52
 
 
53
  for ( int x = 0; x < fieldList->size( ); x++ )
 
54
  {
 
55
    cboxXCoordinate->addItem( fieldList->at( x ) );
 
56
    cboxYCoordinate->addItem( fieldList->at( x ) );
 
57
 
 
58
    //Take a guess in an attempt to auto select the currect field
 
59
    if ( fieldList->at( x ).contains( QRegExp( "( ^x|^lon|^east )", Qt::CaseInsensitive ) ) )
 
60
    {
 
61
      xCoordinateIndex = x;
 
62
    }
 
63
 
 
64
    if ( fieldList->at( x ).contains( QRegExp( "( ^y|^lat|^north )", Qt::CaseInsensitive ) ) )
 
65
    {
 
66
      yCoordinateIndex = x;
 
67
    }
 
68
 
 
69
  }
 
70
 
 
71
  cboxXCoordinate->setCurrentIndex( xCoordinateIndex );
 
72
  cboxYCoordinate->setCurrentIndex( yCoordinateIndex );
 
73
}
 
74
 
 
75
/*
 
76
 *
 
77
 * Public and Private Slots
 
78
 *
 
79
 */
 
80
/**
 
81
* Slot called when the ok/accept button is pressed
 
82
*/
 
83
void eVisDatabaseLayerFieldSelectionGui::on_buttonBox_accepted( )
 
84
{
 
85
  //emit the signal to draw the layer
 
86
  emit eVisDatabaseLayerFieldsSelected( leLayerName->text( ), cboxXCoordinate->currentText( ), cboxYCoordinate->currentText( ) );
 
87
 
 
88
  //close the gui component
 
89
  close( );
 
90
 
 
91
  //reset the layer name line edit
 
92
  leLayerName->setText( "" );
 
93
}
 
94
 
 
95
/**
 
96
* Slot called then the cancel button is pressed
 
97
*/
 
98
void eVisDatabaseLayerFieldSelectionGui::on_buttonBox_rejected( )
 
99
{
 
100
  close( );
 
101
  leLayerName->setText( "" );
 
102
}