Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actions Dialogue Duplicate Button #57647

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/gui/vector/qgsattributeactiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ QgsAttributeActionDialog::QgsAttributeActionDialog( const QgsActionManager &acti
connect( mMoveDownButton, &QAbstractButton::clicked, this, &QgsAttributeActionDialog::moveDown );
connect( mRemoveButton, &QAbstractButton::clicked, this, &QgsAttributeActionDialog::remove );
connect( mAddButton, &QAbstractButton::clicked, this, &QgsAttributeActionDialog::insert );
connect( mDuplicateButton, &QAbstractButton::clicked, this, &QgsAttributeActionDialog::duplicate );
connect( mAddDefaultActionsButton, &QAbstractButton::clicked, this, &QgsAttributeActionDialog::addDefaultActions );

init( actions, mLayer->attributeTableConfig() );
Expand Down Expand Up @@ -296,6 +297,35 @@ void QgsAttributeActionDialog::insert()
}
}

void QgsAttributeActionDialog::duplicate()
{
// Add the action details as a new row in the table.
const int pos = mAttributeActionTable->rowCount();
const int row = mAttributeActionTable->currentRow();

QgsAttributeActionPropertiesDialog dlg(
static_cast<Qgis::AttributeActionType>( mAttributeActionTable->item( row, Type )->data( Role::ActionType ).toInt() ),
mAttributeActionTable->item( row, Description )->text(),
mAttributeActionTable->item( row, ShortTitle )->text(),
mAttributeActionTable->verticalHeaderItem( row )->data( Qt::UserRole ).toString(),
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(),
mAttributeActionTable->item( row, EnabledOnlyWhenEditable )->checkState() == Qt::Checked,
mLayer
);

dlg.setWindowTitle( tr( "Duplicate Action" ) );

if ( dlg.exec() )
{
const QString name = uniqueName( dlg.description() );

insertRow( pos, dlg.type(), name, dlg.actionText(), dlg.iconPath(), dlg.capture(), dlg.shortTitle(), dlg.actionScopes(), dlg.notificationMessage(), dlg.isEnabledOnlyWhenEditable() );
}
}

void QgsAttributeActionDialog::updateButtons()
{
QList<QTableWidgetItem *> selection = mAttributeActionTable->selectedItems();
Expand All @@ -314,6 +344,7 @@ void QgsAttributeActionDialog::updateButtons()
}

mRemoveButton->setEnabled( hasSelection );
mDuplicateButton->setEnabled( hasSelection );
}

void QgsAttributeActionDialog::addDefaultActions()
Expand Down
1 change: 1 addition & 0 deletions src/gui/vector/qgsattributeactiondialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class GUI_EXPORT QgsAttributeActionDialog: public QWidget, private Ui::QgsAttrib
void moveDown();
void remove();
void insert();
void duplicate();
void addDefaultActions();
void itemDoubleClicked( QTableWidgetItem *item );
void updateButtons();
Expand Down
73 changes: 44 additions & 29 deletions src/ui/qgsattributeactiondialogbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="mRemoveButton">
<property name="sizePolicy">
Expand All @@ -88,7 +101,35 @@
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="mAddButton">
<property name="toolTip">
<string>Add a new action</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QPushButton" name="mDuplicateButton">
<property name="toolTip">
<string>Duplicate an action</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionDuplicateLayout.svg</normaloff>:/images/themes/default/mActionDuplicateLayout.svg</iconset>
</property>
</widget>
</item>
<item row="1" column="6">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -101,7 +142,7 @@
</property>
</spacer>
</item>
<item row="1" column="6">
<item row="1" column="7">
<widget class="QPushButton" name="mAddDefaultActionsButton">
<property name="text">
<string>Create Default Actions</string>
Expand All @@ -128,7 +169,7 @@
</property>
</widget>
</item>
<item row="0" column="0" colspan="7">
<item row="0" column="0" colspan="8">
<widget class="QTableWidget" name="mAttributeActionTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
Expand Down Expand Up @@ -193,33 +234,6 @@
</column>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="mAddButton">
<property name="toolTip">
<string>Add a new action</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -273,6 +287,7 @@
<tabstop>mMoveDownButton</tabstop>
<tabstop>mRemoveButton</tabstop>
<tabstop>mAddButton</tabstop>
<tabstop>mDuplicateButton</tabstop>
<tabstop>mAddDefaultActionsButton</tabstop>
<tabstop>mShowInAttributeTable</tabstop>
<tabstop>mAttributeTableWidgetType</tabstop>
Expand Down
Loading