@@ -68,24 +68,26 @@ void QgsAttributeActionDialog::init()
6868 attributeActionTable->setRowCount ( 0 );
6969
7070 // 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++ )
7572 {
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 () );
7775 }
7876}
7977
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 )
8179{
80+ QTableWidgetItem* item;
8281 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 ();
8688 item->setFlags ( item->flags () & ~( Qt::ItemIsEditable | Qt::ItemIsUserCheckable ) );
8789 item->setCheckState ( capture ? Qt::Checked : Qt::Unchecked );
88- attributeActionTable->setItem ( row, 2 , item );
90+ attributeActionTable->setItem ( row, 3 , item );
8991}
9092
9193void QgsAttributeActionDialog::moveUp ()
@@ -208,15 +210,15 @@ void QgsAttributeActionDialog::insert( int pos )
208210 if ( pos >= numRows )
209211 {
210212 // 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 () );
212214 }
213215 else
214216 {
215217 // 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 );
220222 }
221223 }
222224}
@@ -253,12 +255,13 @@ void QgsAttributeActionDialog::apply()
253255 mActions ->clearActions ();
254256 for ( int i = 0 ; i < attributeActionTable->rowCount (); ++i )
255257 {
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 ();
258261 if ( !name.isEmpty () && !action.isEmpty () )
259262 {
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 );
262265 }
263266 }
264267}
@@ -292,8 +295,9 @@ void QgsAttributeActionDialog::rowSelected( int row )
292295 if ( item )
293296 {
294297 // 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 () );
297301 captureCB->setChecked ( item->checkState () == Qt::Checked );
298302 }
299303}
0 commit comments