qgssnappingdialog2_WithoutNewSignal.diff

the same as before, but without introducing a new signal - cmoe -, 2010-11-19 06:12 AM

Download (5.63 KB)

View differences:

src/app/qgssnappingdialog.cpp (Arbeitskopie)
27 27
#include <QComboBox>
28 28
#include <QLineEdit>
29 29
#include <QDockWidget>
30
#include <QPushButton>
30 31

  
31 32

  
32 33
class QgsSnappingDock : public QDockWidget
......
63 64
  else
64 65
  {
65 66
    connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( apply() ) );
67
    connect( mButtonBox->button(QDialogButtonBox::Apply), SIGNAL( clicked() ), this, SLOT( apply() ) );
66 68
  }
67
  connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ), this, SLOT( update() ) );
68
  connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( update() ) );
69
  connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ), this, SLOT( connectUpdate( QgsMapLayer *) ) );
69 70

  
70 71
  update();
71 72

  
......
106 107
  QSettings myQsettings;
107 108
  bool myDockFlag = myQsettings.value( "/qgis/dockSnapping", false ).toBool();
108 109

  
109
  double defaultSnapppingTolerance = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble();
110
  int defaultSnapppingUnit = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt();
110
  double defaultSnappingTolerance = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble();
111
  int defaultSnappingUnit = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt();
111 112
  QString defaultSnappingString = myQsettings.value( "/qgis/digitizing/default_snap_mode", "to vertex" ).toString();
112 113

  
113 114
  int defaultSnappingStringIdx = 0;
......
133 134

  
134 135
  mLayerTreeWidget->clear();
135 136

  
136
  for ( int i = 0; i < mMapCanvas->layerCount(); ++i )
137
  QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
138
  int a = mapLayers.count();
139
  QMap< QString, QgsMapLayer *>::iterator it;
140
  for ( it = mapLayers.begin(); it != mapLayers.end() ; ++it )
137 141
  {
138
    QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( mMapCanvas->layer( i ) );
142
    QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( it.value() );
139 143
    if ( !currentVectorLayer )
140 144
      continue;
141 145

  
......
160 164
    QLineEdit *leTolerance = new QLineEdit( mLayerTreeWidget );
161 165
    QDoubleValidator *validator = new QDoubleValidator( leTolerance );
162 166
    leTolerance->setValidator( validator );
163
    leTolerance->setText( QString::number( defaultSnapppingTolerance, 'f' ) );
167
    leTolerance->setText( QString::number( defaultSnappingTolerance, 'f' ) );
164 168

  
165 169
    mLayerTreeWidget->setItemWidget( item, 3, leTolerance );
166 170

  
......
168 172
    QComboBox *cbxUnits = new QComboBox( mLayerTreeWidget );
169 173
    cbxUnits->insertItem( 0, tr( "map units" ) );
170 174
    cbxUnits->insertItem( 1, tr( "pixels" ) );
171
    cbxUnits->setCurrentIndex( defaultSnapppingUnit );
175
    cbxUnits->setCurrentIndex( defaultSnappingUnit );
172 176
    mLayerTreeWidget->setItemWidget( item, 4, cbxUnits );
173 177

  
174 178
    int idx = layerIdList.indexOf( currentVectorLayer->getLayerID() );
......
262 266
  else
263 267
    QDialog::show();
264 268
}
269

  
270

  
271
void QgsSnappingDialog::connectUpdate(QgsMapLayer * theMapLayer)
272
{
273
  connect( theMapLayer,SIGNAL( destroyed() ),this,SLOT( update() ) );
274
  update();
275
}
src/app/qgssnappingdialog.h (Arbeitskopie)
18 18
#ifndef QGSSNAPPINGDIALOG_H
19 19
#define QGSSNAPPINGDIALOG_H
20 20

  
21
#include "qgsmaplayer.h"
21 22
#include "ui_qgssnappingdialogbase.h"
22 23

  
23 24
class QDockWidget;
......
41 42
    //! apply the changes
42 43
    void apply();
43 44

  
44
    //! update the Dialog
45
    void update();
46

  
47 45
    //! show dialog or dock
48 46
    void show();
49 47

  
48
    //! connect to the layers destroyed() and then update()
49
    void connectUpdate(QgsMapLayer* theMapLayer);
50

  
50 51
  protected:
51 52
    /**Constructor
52 53
    @param canvas pointer to the map canvas (for detecting which vector layers are loaded
......
67 68
    QgsMapCanvas* mMapCanvas;
68 69

  
69 70
    QDockWidget *mDock;
71

  
72
  private slots:
73
    //! update the Dialog
74
    void update();
70 75
};
71 76

  
72 77
#endif
src/app/qgsprojectproperties.h (Arbeitskopie)
21 21
#include "ui_qgsprojectpropertiesbase.h"
22 22
#include "qgis.h"
23 23
#include "qgisgui.h"
24
#include "qgssnappingdialog.h"
25 24
#include "qgscontexthelp.h"
26 25

  
27 26
class QgsMapCanvas;
src/core/qgsmaplayerregistry.cpp (Arbeitskopie)
111 111
  {
112 112
    emit layerWillBeRemoved( it.key() );
113 113
    delete it.value(); // delete the map layer
114
    mMapLayers.remove( it.key() );
114 115
  }
115 116
  mMapLayers.clear();
116 117

  
src/ui/qgssnappingdialogbase.ui (Arbeitskopie)
30 30
     </property>
31 31
     <column>
32 32
      <property name="text">
33
       <string> </string>
33
       <string/>
34 34
      </property>
35 35
     </column>
36 36
     <column>
......
61 61
      <enum>Qt::Horizontal</enum>
62 62
     </property>
63 63
     <property name="standardButtons">
64
      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
64
      <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
65 65
     </property>
66 66
    </widget>
67 67
   </item>