Skip to content

Commit f03a94f

Browse files
committedMay 2, 2016
Fix crash
1 parent 4730047 commit f03a94f

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed
 

‎python/core/qgsaction.sip

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,36 @@ class QgsAction
3333
OpenUrl,
3434
};
3535

36-
QgsAction( ActionType type, const QString& name, const QString& action, bool capture );
36+
/**
37+
* Create a new QgsAction
38+
*
39+
* @param type The type of this action
40+
* @param description A human readable description string
41+
* @param action The action text. Its interpretation depends on the type
42+
* @param capture If this is set to true, the output will be captured when an action is run
43+
*/
44+
QgsAction( ActionType type, const QString& description, const QString& action, bool capture );
3745

38-
QgsAction( ActionType type, const QString& name, const QString& action, const QString& icon, bool capture );
3946

40-
//! The name of the action
47+
/**
48+
* Create a new QgsAction
49+
*
50+
* @param type The type of this action
51+
* @param description A human readable description string
52+
* @param action The action text. Its interpretation depends on the type
53+
* @param icon Path to an icon for this action
54+
* @param capture If this is set to true, the output will be captured when an action is run
55+
* @param shortTitle A short string used to label user interface elements like buttons
56+
*/
57+
QgsAction( ActionType type, const QString& description, const QString& action, const QString& icon, bool capture, const QString& shortTitle = QString() );
58+
59+
60+
//! The name of the action. This may be a longer description.
4161
QString name() const;
4262

63+
//! The short title is used to label user interface elements like buttons
64+
QString shortTitle() const;
65+
4366
//! The path to the icon
4467
QString iconPath() const;
4568

‎python/gui/attributetable/qgsattributetabledelegate.sip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,9 @@ class QgsAttributeTableDelegate : QItemDelegate
3939
void setEditorData( QWidget *editor, const QModelIndex &index ) const;
4040

4141
void setFeatureSelectionModel( QgsFeatureSelectionModel* featureSelectionModel );
42+
43+
/**
44+
* Set an image that represents an action widget
45+
*/
46+
void setActionWidgetImage( const QImage& image );
4247
};

‎src/gui/attributetable/qgsattributetablefiltermodel.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,16 @@ int QgsAttributeTableFilterModel::columnCount( const QModelIndex& parent ) const
111111

112112
void QgsAttributeTableFilterModel::setAttributeTableConfig( const QgsAttributeTableConfig& config )
113113
{
114+
mConfig = config;
115+
mConfig.update( layer()->fields() );
116+
114117
int columnIndex = 0;
115118
int configIndex = 0;
116119
bool resetModel = false;
117120

118-
for ( ; configIndex < config.columns().size(); ++configIndex )
121+
for ( ; configIndex < mConfig.columns().size(); ++configIndex )
119122
{
120-
const QgsAttributeTableConfig::ColumnConfig& columnConfig = config.columns().at( configIndex );
123+
const QgsAttributeTableConfig::ColumnConfig& columnConfig = mConfig.columns().at( configIndex );
121124

122125
// Hidden? No reason for further checks
123126
if ( columnConfig.mHidden )
@@ -144,7 +147,6 @@ void QgsAttributeTableFilterModel::setAttributeTableConfig( const QgsAttributeTa
144147
resetModel = true;
145148
}
146149

147-
148150
// New column? append
149151
Q_ASSERT( mColumnMapping.size() == columnIndex );
150152
if ( columnConfig.mType == QgsAttributeTableConfig::Action )
@@ -183,6 +185,7 @@ void QgsAttributeTableFilterModel::setSourceModel( QgsAttributeTableModel* sourc
183185
}
184186

185187
QSortFilterProxyModel::setSourceModel( sourceModel );
188+
disconnect( mTableModel, SIGNAL( columnsAboutToBeInserted( QModelIndex, int, int ) ), this, SLOT( onColumnsAboutToBeInserted() ) );
186189
}
187190

188191
bool QgsAttributeTableFilterModel::selectedOnTop()
@@ -290,6 +293,11 @@ void QgsAttributeTableFilterModel::selectionChanged()
290293
}
291294
}
292295

296+
void QgsAttributeTableFilterModel::onColumnsAboutToBeInserted()
297+
{
298+
setAttributeTableConfig( mConfig );
299+
}
300+
293301
void QgsAttributeTableFilterModel::generateListOfVisibleFeatures()
294302
{
295303
if ( !layer() )

‎src/gui/attributetable/qgsattributetablefiltermodel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ class GUI_EXPORT QgsAttributeTableFilterModel: public QSortFilterProxyModel, pub
228228

229229
private slots:
230230
void selectionChanged();
231+
void onColumnsAboutToBeInserted();
231232

232233
private:
233234
QgsFeatureIds mFilteredFeatures;
@@ -236,6 +237,7 @@ class GUI_EXPORT QgsAttributeTableFilterModel: public QSortFilterProxyModel, pub
236237
bool mSelectedOnTop;
237238
QgsAttributeTableModel* mTableModel;
238239

240+
QgsAttributeTableConfig mConfig;
239241
QVector<int> mColumnMapping;
240242
};
241243

0 commit comments

Comments
 (0)
Please sign in to comment.