Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Truncate action text when showing a preview in the action manager table
There's no point showing the full action text in the table, as the table
columns are generally only wide enough to show <20 characters

Otherwise large actions (such as python scripts) can cause huge slowdowns in the
vector layer properties dialog when we try to insert the entire script
into a table cell...
  • Loading branch information
nyalldawson committed Oct 21, 2020
1 parent e304d4d commit 9aa805c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/gui/vector/qgsattributeactiondialog.cpp
Expand Up @@ -122,7 +122,9 @@ void QgsAttributeActionDialog::insertRow( int row, const QgsAction &action )
mAttributeActionTable->setItem( row, ShortTitle, new QTableWidgetItem( action.shortTitle() ) );

// Action text
mAttributeActionTable->setItem( row, ActionText, new QTableWidgetItem( action.command() ) );
item = new QTableWidgetItem( action.command().length() > 30 ? action.command().left( 27 ) + "" : action.command() );
item->setData( Qt::UserRole, action.command() );
mAttributeActionTable->setItem( row, ActionText, item );

// Capture output
item = new QTableWidgetItem();
Expand Down Expand Up @@ -224,7 +226,7 @@ QgsAction QgsAttributeActionDialog::rowToAction( int row ) const
{
QgsAction action( static_cast<QgsAction::ActionType>( mAttributeActionTable->item( row, Type )->data( Qt::UserRole ).toInt() ),
mAttributeActionTable->item( row, Description )->text(),
mAttributeActionTable->item( row, ActionText )->text(),
mAttributeActionTable->item( row, ActionText )->data( Qt::UserRole ).toString(),
mAttributeActionTable->verticalHeaderItem( row )->data( Qt::UserRole ).toString(),
mAttributeActionTable->item( row, Capture )->checkState() == Qt::Checked,
mAttributeActionTable->item( row, ShortTitle )->text(),
Expand Down Expand Up @@ -333,7 +335,7 @@ void QgsAttributeActionDialog::itemDoubleClicked( QTableWidgetItem *item )
mAttributeActionTable->item( row, Description )->text(),
mAttributeActionTable->item( row, ShortTitle )->text(),
mAttributeActionTable->verticalHeaderItem( row )->data( Qt::UserRole ).toString(),
mAttributeActionTable->item( row, ActionText )->text(),
mAttributeActionTable->item( row, ActionText )->data( Qt::UserRole ).toString(),
mAttributeActionTable->item( row, Capture )->checkState() == Qt::Checked,
mAttributeActionTable->item( row, ActionScopes )->data( Qt::UserRole ).value<QSet<QString>>(),
mAttributeActionTable->item( row, NotificationMessage )->text(),
Expand All @@ -349,7 +351,8 @@ void QgsAttributeActionDialog::itemDoubleClicked( QTableWidgetItem *item )
mAttributeActionTable->item( row, Type )->setText( textForType( actionProperties.type() ) );
mAttributeActionTable->item( row, Description )->setText( actionProperties.description() );
mAttributeActionTable->item( row, ShortTitle )->setText( actionProperties.shortTitle() );
mAttributeActionTable->item( row, ActionText )->setText( actionProperties.actionText() );
mAttributeActionTable->item( row, ActionText )->setText( actionProperties.actionText().length() > 30 ? actionProperties.actionText().left( 27 ) + "" : actionProperties.actionText() );
mAttributeActionTable->item( row, ActionText )->setData( Qt::UserRole, actionProperties.actionText() );
mAttributeActionTable->item( row, Capture )->setCheckState( actionProperties.capture() ? Qt::Checked : Qt::Unchecked );
mAttributeActionTable->item( row, NotificationMessage )->setText( actionProperties.notificationMessage() );
mAttributeActionTable->item( row, EnabledOnlyWhenEditable )->setCheckState( actionProperties.isEnabledOnlyWhenEditable() ? Qt::Checked : Qt::Unchecked );
Expand Down

0 comments on commit 9aa805c

Please sign in to comment.