@@ -68,24 +68,26 @@ void QgsAttributeActionDialog::init()
68
68
attributeActionTable->setRowCount ( 0 );
69
69
70
70
// Populate with our actions.
71
- QgsAttributeAction::AttributeActions::const_iterator
72
- iter = mActions ->begin ();
73
- int i = 0 ;
74
- for ( ; iter != mActions ->end (); ++iter, ++i )
71
+ for ( int i = 0 ; i < mActions ->size (); i++ )
75
72
{
76
- insertRow ( i, iter->name (), iter->action (), iter->capture () );
73
+ const QgsAction action = ( *mActions )[i];
74
+ insertRow ( i, action.type (), action.name (), action.action (), action.capture () );
77
75
}
78
76
}
79
77
80
- void QgsAttributeActionDialog::insertRow ( int row, const QString &name, const QString &action, bool capture )
78
+ void QgsAttributeActionDialog::insertRow ( int row, QgsAction::ActionType type, const QString &name, const QString &action, bool capture )
81
79
{
80
+ QTableWidgetItem* item;
82
81
attributeActionTable->insertRow ( row );
83
- attributeActionTable->setItem ( row, 0 , new QTableWidgetItem ( name ) );
84
- attributeActionTable->setItem ( row, 1 , new QTableWidgetItem ( action ) );
85
- QTableWidgetItem* item = new QTableWidgetItem ();
82
+ item = new QTableWidgetItem ( actionType->itemText ( type ) );
83
+ item->setFlags ( item->flags () & ~Qt::ItemIsEditable );
84
+ attributeActionTable->setItem ( row, 0 , item );
85
+ attributeActionTable->setItem ( row, 1 , new QTableWidgetItem ( name ) );
86
+ attributeActionTable->setItem ( row, 2 , new QTableWidgetItem ( action ) );
87
+ item = new QTableWidgetItem ();
86
88
item->setFlags ( item->flags () & ~( Qt::ItemIsEditable | Qt::ItemIsUserCheckable ) );
87
89
item->setCheckState ( capture ? Qt::Checked : Qt::Unchecked );
88
- attributeActionTable->setItem ( row, 2 , item );
90
+ attributeActionTable->setItem ( row, 3 , item );
89
91
}
90
92
91
93
void QgsAttributeActionDialog::moveUp ()
@@ -208,15 +210,15 @@ void QgsAttributeActionDialog::insert( int pos )
208
210
if ( pos >= numRows )
209
211
{
210
212
// Expand the table to have a row with index pos
211
- insertRow ( pos, name, actionAction->text (), captureCB->isChecked () );
213
+ insertRow ( pos, ( QgsAction::ActionType ) actionType-> currentIndex (), name, actionAction->text (), captureCB->isChecked () );
212
214
}
213
215
else
214
216
{
215
217
// Update existing row
216
- attributeActionTable->item ( pos, 0 )->setText ( name );
217
- attributeActionTable->item ( pos, 1 )->setText ( actionAction-> text () );
218
- attributeActionTable->item ( pos, 2 )->setCheckState (
219
- captureCB->isChecked () ? Qt::Checked : Qt::Unchecked );
218
+ attributeActionTable->item ( pos, 0 )->setText ( actionType-> currentText () );
219
+ attributeActionTable->item ( pos, 1 )->setText ( name );
220
+ attributeActionTable->item ( pos, 2 )->setText ( actionAction-> text () );
221
+ attributeActionTable-> item ( pos, 3 )-> setCheckState ( captureCB->isChecked () ? Qt::Checked : Qt::Unchecked );
220
222
}
221
223
}
222
224
}
@@ -253,12 +255,13 @@ void QgsAttributeActionDialog::apply()
253
255
mActions ->clearActions ();
254
256
for ( int i = 0 ; i < attributeActionTable->rowCount (); ++i )
255
257
{
256
- const QString &name = attributeActionTable->item ( i, 0 )->text ();
257
- const QString &action = attributeActionTable->item ( i, 1 )->text ();
258
+ const QgsAction::ActionType type = ( QgsAction::ActionType ) actionType->findText ( attributeActionTable->item ( i, 0 )->text () );
259
+ const QString &name = attributeActionTable->item ( i, 1 )->text ();
260
+ const QString &action = attributeActionTable->item ( i, 2 )->text ();
258
261
if ( !name.isEmpty () && !action.isEmpty () )
259
262
{
260
- QTableWidgetItem *item = attributeActionTable->item ( i, 2 );
261
- mActions ->addAction ( name, action, item->checkState () == Qt::Checked );
263
+ QTableWidgetItem *item = attributeActionTable->item ( i, 3 );
264
+ mActions ->addAction ( type, name, action, item->checkState () == Qt::Checked );
262
265
}
263
266
}
264
267
}
@@ -292,8 +295,9 @@ void QgsAttributeActionDialog::rowSelected( int row )
292
295
if ( item )
293
296
{
294
297
// Only if a populated row was selected
295
- actionName->setText ( attributeActionTable->item ( row, 0 )->text () );
296
- actionAction->setText ( attributeActionTable->item ( row, 1 )->text () );
298
+ actionType->setCurrentIndex ( actionType->findText ( attributeActionTable->item ( row, 0 )->text () ) );
299
+ actionName->setText ( attributeActionTable->item ( row, 1 )->text () );
300
+ actionAction->setText ( attributeActionTable->item ( row, 2 )->text () );
297
301
captureCB->setChecked ( item->checkState () == Qt::Checked );
298
302
}
299
303
}
0 commit comments