legendiface_2672_2.patch

Improved patch - Andres Manz -, 2010-04-24 03:28 PM

Download (8.06 KB)

View differences:

python/gui/qgslegendinterface.sip (working copy)
21 21

  
22 22
    //! Return all layers in the project in legend order
23 23
    //! @note added in 1.5
24
    virtual QList< QgsMapLayer * > layers() const = 0;
24
    virtual QList< QgsMapLayer * > layers() const =0;
25 25

  
26
    //! Check if a group exists
27
    //! @note added in 1.5
28
    virtual bool groupExists( int groupIndex ) =0;
29

  
30
    //! Check if a group is expanded
31
    //! @note added in 1.5
32
    virtual bool isGroupExpanded( int groupIndex ) =0;
33

  
34
    //! Check if a group is visible
35
    //! @note added in 1.5
36
    virtual bool isGroupVisible( int groupIndex ) =0;
37

  
38
    //! Check if a layer is visible
39
    //! @note added in 1.5
40
    virtual bool isLayerVisible( QgsMapLayer * ml ) =0;
41

  
26 42
  signals:
27 43

  
28 44
    //! emitted when a group index has changed
......
39 55
    //! Move a layer to a group
40 56
    virtual void moveLayer( QgsMapLayer * layer, int groupIndex ) =0;
41 57

  
58
    //! Collapse or expand a group
59
    //! @note added in 1.5
60
    virtual void setGroupExpanded( int groupIndex, bool expand ) =0;
61

  
62
    //! Set the visibility of a group
63
    //! @note added in 1.5
64
    virtual void setGroupVisible( int groupIndex, bool visible ) =0;
65

  
66
    //! Set the visibility of a layer
67
    //! @note added in 1.5
68
    virtual void setLayerVisible( QgsMapLayer * ml, bool visible ) =0;
69

  
42 70
    //! refresh layer symbology
43
    //! \note added in 1.5
71
    //! @note added in 1.5
44 72
    virtual void refreshLayerSymbology( QgsMapLayer *layer ) =0;
45 73
};
46 74

  
src/app/legend/qgsapplegendinterface.h (working copy)
38 38
    /** Constructor */
39 39
    explicit QgsAppLegendInterface( QgsLegend * legend );
40 40

  
41
    /** Virtual destructor */
41
    /** Destructor */
42 42
    ~QgsAppLegendInterface();
43 43

  
44 44
    //! Return a string list of groups
......
47 47
    //! Return all layers in the project in legend order
48 48
    QList< QgsMapLayer * > layers() const;
49 49

  
50
    //! Check if a group exists
51
    bool groupExists( int groupIndex );
52

  
53
    //! Check if a group is expanded
54
    bool isGroupExpanded( int groupIndex );
55

  
56
    //! Check if a group is visible
57
    bool isGroupVisible( int groupIndex );
58

  
59
    //! Check if a layer is visible
60
    bool isLayerVisible( QgsMapLayer * ml );
61

  
50 62
  public slots:
51 63

  
52 64
    //! Add a new group
......
61 73
    //! Update an index
62 74
    void updateIndex( QModelIndex oldIndex, QModelIndex newIndex );
63 75

  
76
    //! Collapse or expand a group
77
    virtual void setGroupExpanded( int groupIndex, bool expand );
78

  
79
    //! Set the visibility of a group
80
    virtual void setGroupVisible( int groupIndex, bool visible );
81

  
82
    //! Set the visibility of a layer
83
    virtual void setLayerVisible( QgsMapLayer * ml, bool visible );
84

  
64 85
    //! refresh layer symbology
65 86
    void refreshLayerSymbology( QgsMapLayer *ml );
66 87

  
src/app/legend/qgslegend.cpp (working copy)
480 480
  mPixmaps.mProjectionErrorPixmap = QgisApp::getThemePixmap( "/mIconProjectionProblem.png" );
481 481
}
482 482

  
483
Qt::CheckState QgsLegend::layerCheckState( QgsMapLayer * layer )
484
{
485
  QgsLegendLayer * ll = findLegendLayer( layer );
486

  
487
  return ll ? Qt::Unchecked : ll->checkState( 0 );
488
}
489

  
483 490
int QgsLegend::getItemPos( QTreeWidgetItem* item )
484 491
{
485 492
  int counter = 1;
......
548 555
  doItemsLayout();
549 556
}
550 557

  
558
void QgsLegend::setLayerVisible( QgsMapLayer * layer, bool visible )
559
{
560
  QgsLegendLayer * ll = findLegendLayer( layer );
561
  if ( ll )
562
  {
563
    Qt::CheckState cs = visible ? Qt::Checked : Qt::Unchecked;
564
    ll->setCheckState( 0, cs );
565
  }
566
}
567

  
551 568
void QgsLegend::setMapCanvas( QgsMapCanvas * canvas )
552 569
{
553 570
  if ( mMapCanvas )
src/app/legend/qgslegend.h (working copy)
179 179
    /**Returns structure with legend pixmaps*/
180 180
    QgsLegendPixmaps& pixmaps() { return mPixmaps; }
181 181

  
182
    /**Returns a layers check state*/
183
    Qt::CheckState layerCheckState( QgsMapLayer * layer );
182 184

  
185

  
183 186
    void updateCheckStates( QTreeWidgetItem* item, Qt::CheckState state ) { item->setData( 0, Qt::UserRole, state ); }
184 187

  
185 188
  public slots:
......
187 190
    /*!Adds a new layer group with the maplayer to the canvas*/
188 191
    void addLayer( QgsMapLayer * layer );
189 192

  
193
    void setLayerVisible( QgsMapLayer * layer, bool visible );
194

  
190 195
    void setMapCanvas( QgsMapCanvas * canvas );
191 196

  
192 197
    /**Updates symbology items for a layer*/
src/app/legend/qgsapplegendinterface.cpp (working copy)
54 54
  }
55 55
}
56 56

  
57
void QgsAppLegendInterface::setGroupExpanded( int groupIndex, bool expand )
58
{
59
  mLegend->setExpanded( mLegend->model()->index( groupIndex, 0 ), expand );
60
}
61

  
62
void QgsAppLegendInterface::setGroupVisible( int groupIndex, bool visible )
63
{
64
  if ( !groupExists( groupIndex ) )
65
  {
66
    return;
67
  }
68

  
69
  Qt::CheckState state = visible ? Qt::Checked : Qt::Unchecked;
70
  mLegend->topLevelItem( groupIndex )->setCheckState( 0, state );
71
}
72

  
73
void QgsAppLegendInterface::setLayerVisible( QgsMapLayer * ml, bool visible )
74
{
75
  mLegend->setLayerVisible( ml, visible );
76
}
77

  
57 78
QStringList QgsAppLegendInterface::groups()
58 79
{
59 80
  return mLegend->groups();
60 81
}
61 82

  
83
bool QgsAppLegendInterface::groupExists( int groupIndex )
84
{
85
  QModelIndex mi = mLegend->model()->index( groupIndex, 0 );
86
  return ( mi.isValid() &&
87
           mLegend->isLegendGroup( mi ) );
88
}
89

  
90
bool QgsAppLegendInterface::isGroupExpanded( int groupIndex )
91
{
92
  return mLegend->isExpanded( mLegend->model()->index( groupIndex, 0 ) );
93
}
94

  
95
bool QgsAppLegendInterface::isGroupVisible( int groupIndex )
96
{
97
  if ( !groupExists( groupIndex ) )
98
  {
99
    return false;
100
  }
101

  
102
  return ( Qt::Checked == mLegend->topLevelItem( groupIndex )->checkState( 0 ) );
103
}
104

  
105
bool QgsAppLegendInterface::isLayerVisible( QgsMapLayer * ml )
106
{
107
  return ( Qt::Checked == mLegend->layerCheckState( ml ) );
108
}
109

  
62 110
QList< QgsMapLayer * > QgsAppLegendInterface::layers() const
63 111
{
64 112
  QList< QgsMapLayer * > items;
src/gui/qgslegendinterface.h (working copy)
48 48
    //! @note added in 1.5
49 49
    virtual QList< QgsMapLayer * > layers() const = 0;
50 50

  
51
    //! Check if a group exists
52
    //! @note added in 1.5
53
    virtual bool groupExists( int groupIndex ) = 0;
54

  
55
    //! Check if a group is expanded
56
    //! @note added in 1.5
57
    virtual bool isGroupExpanded( int groupIndex ) = 0;
58

  
59
    //! Check if a group is visible
60
    //! @note added in 1.5
61
    virtual bool isGroupVisible( int groupIndex ) = 0;
62

  
63
    //! Check if a layer is visible
64
    //! @note added in 1.5
65
    virtual bool isLayerVisible( QgsMapLayer * ml ) = 0;
66

  
51 67
  signals:
52 68

  
53 69
    //! emitted when a group index has changed
......
64 80
    //! Move a layer to a group
65 81
    virtual void moveLayer( QgsMapLayer * ml, int groupIndex ) = 0;
66 82

  
83
    //! Collapse or expand a group
84
    //! @note added in 1.5
85
    virtual void setGroupExpanded( int groupIndex, bool expand ) = 0;
86

  
87
    //! Set the visibility of a group
88
    //! @note added in 1.5
89
    virtual void setGroupVisible( int groupIndex, bool visible ) = 0;
90

  
91
    //! Set the visibility of a layer
92
    //! @note added in 1.5
93
    virtual void setLayerVisible( QgsMapLayer * ml, bool visible ) = 0;
94

  
67 95
    //! Refresh layer symbology
68
    // @noted added in 1.5
96
    //! @note added in 1.5
69 97
    virtual void refreshLayerSymbology( QgsMapLayer *ml ) = 0;
70 98
};
71 99