Skip to content

Commit 99c50f2

Browse files
author
wonder
committedJul 20, 2009
Documentation of attribute table headers - patch from Vita Cizek.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11113 c8812cc2-4d05-0410-92ff-de0c093fc19c

7 files changed

+291
-6
lines changed
 

‎src/app/attributetable/qgsattributetabledelegate.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ class QgsAttributeTableDelegate : public QItemDelegate
2727
{
2828
Q_OBJECT;
2929
public:
30-
/** Constructor */
30+
/** Constructor
31+
* @param parent parent object
32+
*/
3133
QgsAttributeTableDelegate( QObject* parent = NULL ) :
3234
QItemDelegate( parent ) {};
3335
/** Used to create an editor for when the user tries to

‎src/app/attributetable/qgsattributetabledialog.h

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,42 +45,124 @@ class QgsAttributeTableDialog : public QDialog, private Ui::QgsAttributeTableDia
4545
Q_OBJECT
4646

4747
public:
48+
/**
49+
* Constructor
50+
* @param theLayer layer pointer
51+
* @param parent parent object
52+
* @param flags window flags
53+
*/
4854
QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWidget *parent = 0, Qt::WindowFlags flags = Qt::Window );
4955
~QgsAttributeTableDialog();
5056

5157
public slots:
58+
/**
59+
* Toggles editing mode
60+
*/
5261
void editingToggled();
5362

5463
private slots:
64+
/**
65+
* submits the data
66+
*/
5567
void submit();
68+
/**
69+
* Reverts the changes
70+
*/
5671
void revert();
72+
/**
73+
* Launches search
74+
*/
5775
void search();
76+
/**
77+
* Launches advanced search
78+
*/
5879
void on_mAdvancedSearchButton_clicked();
80+
/**
81+
* Updates the selection
82+
*/
5983
void updateSelection();
84+
/**
85+
* Reads the selection from the layer
86+
*/
6087
void updateSelectionFromLayer();
88+
/**
89+
* Updates selection of a row
90+
*/
6191
void updateRowSelection( int index );
92+
/**
93+
* Updates selection of specifed rows
94+
* @param first first row
95+
* @param last last row
96+
* @param startNewSelection if true, then new selection is started
97+
*/
6298
void updateRowSelection( int first, int last, bool startNewSelection );
6399

100+
/**
101+
* Toggle showing of selected line only
102+
* @param theFlag toggle on if true
103+
*/
64104
void on_cbxShowSelectedOnly_toggled( bool theFlag );
105+
/**
106+
* Copies selected rows to the clipboard
107+
*/
65108
void on_mCopySelectedRowsButton_clicked();
66109

110+
/**
111+
* Toggles editing mode
112+
*/
67113
void on_mToggleEditingButton_toggled();
114+
/**
115+
* Inverts selection
116+
*/
68117
void on_mInvertSelectionButton_clicked();
118+
/**
119+
* Clears selection
120+
*/
69121
void on_mRemoveSelectionButton_clicked();
122+
/**
123+
* Zooms to selected features
124+
*/
70125
void on_mZoomMapToSelectedRowsButton_clicked();
126+
/**
127+
* Moves selected lines to the top
128+
*/
71129
void on_mSelectedToTopButton_clicked();
130+
/**
131+
* Shows advanced actions
132+
*/
72133
void showAdvanced();
134+
/**
135+
* Starts editing mode
136+
*/
73137
void startEditing();
74138

75139
signals:
76-
void editingToggled( QgsMapLayer * );
140+
/**
141+
* Informs that editing mode ha been toggled
142+
* @param layer layer that has been toggled
143+
*/
144+
void editingToggled( QgsMapLayer *layer );
77145

78146
protected:
147+
/**
148+
* Handle closing of the window
149+
* @param event unused
150+
*/
79151
void closeEvent( QCloseEvent* event );
80152

81153
private:
154+
/**
155+
* Initialize column box
156+
*/
82157
void columnBoxInit();
158+
/**
159+
* Returns id of a column
160+
*/
83161
int columnBoxColumnId();
162+
/**
163+
* Performs the search
164+
* @param searchString search query string
165+
*/
84166
void doSearch( QString searchString );
85167

86168
QIcon getThemeIcon( const QString theName );

‎src/app/attributetable/qgsattributetablefiltermodel.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,26 @@
2626
class QgsAttributeTableFilterModel: public QSortFilterProxyModel
2727
{
2828
public:
29+
bool mHideUnselected;
30+
/**
31+
* Constructor
32+
* @param theLayer initializing layer pointer
33+
*/
2934
QgsAttributeTableFilterModel( QgsVectorLayer* theLayer );
35+
/**
36+
* Sorts model by the column
37+
* @param column column to sort by
38+
* @param order sorting order
39+
*/
40+
virtual void sort( int column, Qt::SortOrder order = Qt::AscendingOrder );
3041
//QModelIndex mapToSource ( const QModelIndex & filterIndex ) const;
3142
//QModelIndex mapFromSource ( const QModelIndex & sourceIndex ) const;
32-
bool mHideUnselected;
33-
virtual void sort( int column, Qt::SortOrder order = Qt::AscendingOrder );
3443
protected:
44+
/**
45+
* Returns true if the source row will be accepted
46+
* @param sourceRow row from the source model
47+
* @param sourceParent parent index in the source model
48+
*/
3549
bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const;
3650
private:
3751
QgsVectorLayer* mLayer;

‎src/app/attributetable/qgsattributetableidcolumnpair.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class QgsAttributeTableIdColumnPair
2525
int id;
2626
QVariant columnItem;
2727

28+
/**
29+
* Returns true if this id-column pair is less the the tested one
30+
* @param b the tested id-column pair
31+
*/
2832
bool operator<( const QgsAttributeTableIdColumnPair &b ) const;
2933
};
3034

‎src/app/attributetable/qgsattributetablememorymodel.h

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,70 @@ class QgsAttributeTableMemoryModel: public QgsAttributeTableModel
3232
Q_OBJECT;
3333

3434
public:
35-
QgsAttributeTableMemoryModel( QgsVectorLayer *theLayer );//, QObject *parent = 0);
35+
/**
36+
* Constructor
37+
* @param theLayer layer pointer
38+
*/
39+
QgsAttributeTableMemoryModel( QgsVectorLayer *theLayer );
3640

3741
protected slots:
42+
/**
43+
* Launched when a feature has been deleted
44+
* @param fid feature id
45+
*/
3846
virtual void featureDeleted( int fid );
47+
/**
48+
* Launched when a feature has been deleted
49+
* @param fid feature id
50+
*/
3951
virtual void featureAdded( int fid );
52+
/**
53+
* Launched when layer has been deleted
54+
*/
4055
virtual void layerDeleted();
4156

4257
private slots:
58+
/**
59+
* Launched when attribute has been added
60+
* @param idx attribute index
61+
*/
4362
//virtual void attributeAdded (int idx);
63+
/**
64+
* Launched when attribute has been deleted
65+
* @param idx attribute index
66+
*/
4467
//virtual void attributeDeleted (int idx);
45-
virtual void attributeValueChanged( int fid, int idx, const QVariant &value );
68+
/**
69+
* Launched when layer has been modified
70+
* Rebuilds the model
71+
* @param onlyGeometry true if only geometry has changed
72+
*/
4673
//virtual void layerModified(bool onlyGeometry);
74+
/**
75+
* Launched when attribute value has been changed
76+
* @param fid feature id
77+
* @param idx attribute index
78+
* @param value new value
79+
*/
80+
virtual void attributeValueChanged( int fid, int idx, const QVariant &value );
4781

4882
private:
83+
/**
84+
* Returns data on the given index
85+
* @param index model index
86+
* @param role data role
87+
*/
4988
virtual QVariant data( const QModelIndex &index, int role ) const;
89+
/**
90+
* Updates data on given index
91+
* @param index model index
92+
* @param value new data value
93+
* @param role data role
94+
*/
5095
virtual bool setData( const QModelIndex &index, const QVariant &value, int role );
96+
/**
97+
* Loads the layer into the model
98+
*/
5199
virtual void loadLayer();
52100

53101
QMap<int, QgsFeature> mFeatureMap;

‎src/app/attributetable/qgsattributetablemodel.h

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,40 +31,147 @@ class QgsAttributeTableModel: public QAbstractTableModel
3131
Q_OBJECT
3232

3333
public:
34+
/**
35+
* Constructor
36+
* @param theLayer layer pointer
37+
* @param parent parent pointer
38+
*/
3439
QgsAttributeTableModel( QgsVectorLayer *theLayer, QObject *parent = 0 );
3540

41+
/**
42+
* Returns the number of rows
43+
* @param parent parent index
44+
*/
3645
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
46+
/**
47+
* Returns the number of columns
48+
* @param parent parent index
49+
*/
3750
int columnCount( const QModelIndex &parent = QModelIndex() ) const;
3851

52+
/**
53+
* Returns header data
54+
* @param section required section
55+
* @param orientation horizontal or vertical orientation
56+
* @param role data role
57+
*/
3958
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
59+
/**
60+
* Returns data on the given index
61+
* @param index model index
62+
* @param role data role
63+
*/
4064
virtual QVariant data( const QModelIndex &index, int role ) const;
65+
/**
66+
* Updates data on given index
67+
* @param index model index
68+
* @param value new data value
69+
* @param role data role
70+
*/
4171
virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
72+
/**
73+
* Returns item flags for the index
74+
* @param index model index
75+
*/
4276
Qt::ItemFlags flags( const QModelIndex &index ) const;
4377

78+
/**
79+
* Reloads the model data between indices
80+
* @param index1 start index
81+
* @param index2 end index
82+
*/
4483
void reload( const QModelIndex &index1, const QModelIndex &index2 );
84+
/**
85+
* Resets the model
86+
*/
4587
void resetModel();
88+
/**
89+
* Layout has been changed
90+
*/
4691
void changeLayout();
92+
/**
93+
* Layout will be changed
94+
*/
4795
void incomingChangeLayout();
96+
/**
97+
* Maps feature id to table row
98+
* @param id feature id
99+
*/
48100
int idToRow( const int id ) const;
101+
/**
102+
* Maps row to feature id
103+
* @param id row id
104+
*/
49105
int rowToId( const int id ) const;
106+
/**
107+
* Sorts the model
108+
* @param column column to sort by
109+
* @param order sorting order
110+
*/
50111
virtual void sort( int column, Qt::SortOrder order = Qt::AscendingOrder );
112+
/**
113+
* Swaps two rows
114+
* @param a first row
115+
* @param b second row
116+
*/
51117
void swapRows( int a, int b );
52118

119+
/**
120+
* Returns layer pointer
121+
*/
53122
QgsVectorLayer* layer() const { return mLayer; }
54123

55124
signals:
125+
/**
126+
* Model has been changed
127+
*/
56128
void modelChanged();
129+
/**
130+
* Sets new number of rows
131+
* @param oldNum old row number
132+
* @param newNum new row number
133+
*/
57134
void setNumRows( int oldNum, int newNum );
58135

59136
private slots:
137+
/**
138+
* Launched when attribute has been added
139+
* @param idx attribute index
140+
*/
60141
virtual void attributeAdded( int idx );
142+
/**
143+
* Launched when attribute has been deleted
144+
* @param idx attribute index
145+
*/
61146
virtual void attributeDeleted( int idx );
147+
/**
148+
* Launched when attribute value has been changed
149+
* @param fid feature id
150+
* @param idx attribute index
151+
* @param value new value
152+
*/
62153
virtual void attributeValueChanged( int fid, int idx, const QVariant &value );
154+
/**
155+
* Launched when layer has been modified
156+
* Rebuilds the model
157+
* @param onlyGeometry true if only geometry has changed
158+
*/
63159
virtual void layerModified( bool onlyGeometry );
64160

65161
protected slots:
162+
/**
163+
* Launched when a feature has been deleted
164+
* @param fid feature id
165+
*/
66166
virtual void featureDeleted( int fid );
167+
/**
168+
* Launched when a feature has been added
169+
* @param fid feature id
170+
*/
67171
virtual void featureAdded( int fid );
172+
/**
173+
* Launched when layer has been deleted
174+
*/
68175
virtual void layerDeleted();
69176

70177
protected:
@@ -81,7 +188,13 @@ class QgsAttributeTableModel: public QAbstractTableModel
81188
QMap<int, int> mIdRowMap;
82189
QMap<int, int> mRowIdMap;
83190

191+
/**
192+
* Initializes id <-> row maps
193+
*/
84194
void initIdMaps();
195+
/**
196+
* Loads the layer into the model
197+
*/
85198
virtual void loadLayer();
86199

87200
};

‎src/app/attributetable/qgsattributetableview.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,34 @@ class QgsAttributeTableView: public QTableView
3030
QgsAttributeTableView( QWidget* parent = NULL );
3131
virtual ~QgsAttributeTableView();
3232

33+
/**
34+
* Sets the layer
35+
* @param layer layer pointer
36+
*/
3337
void setLayer( QgsVectorLayer* layer );
3438

39+
/**
40+
* Saves geometry to the settings on close
41+
* @param event not used
42+
*/
3543
void closeEvent( QCloseEvent *event );
44+
/**
45+
* Handles Ctrl or Shift key press
46+
* @param event the key pressed
47+
*/
3648
void keyPressEvent( QKeyEvent *event );
49+
/**
50+
* Handles Ctrl or Shift key release
51+
* @param event the key released
52+
*/
3753
void keyReleaseEvent( QKeyEvent *event );
54+
/**
55+
* Returns true if shift was pressed
56+
*/
3857
bool shiftPressed() { return mShiftPressed; }
58+
/**
59+
* Returns true if ctrl was pressed
60+
*/
3961
bool ctrlPressed() { return mCtrlPressed; }
4062

4163
private:

0 commit comments

Comments
 (0)
Please sign in to comment.