Skip to content

Commit

Permalink
[StyleManager] have separate predefined QActions for start/finish gro…
Browse files Browse the repository at this point in the history
…uping mode
  • Loading branch information
SebDieBln committed Jan 6, 2016
1 parent a9c4179 commit 4d2d001
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
34 changes: 24 additions & 10 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Expand Up @@ -108,10 +108,13 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
this, SLOT( groupRenamed( QStandardItem* ) ) ); this, SLOT( groupRenamed( QStandardItem* ) ) );


QMenu *groupMenu = new QMenu( tr( "Group actions" ), this ); QMenu *groupMenu = new QMenu( tr( "Group actions" ), this );
QAction *groupSymbols = groupMenu->addAction( tr( "Group symbols" ) ); connect( actnGroupSymbols, SIGNAL( triggered() ), this, SLOT( groupSymbolsAction() ) );
groupMenu->addAction( actnGroupSymbols );
connect( actnFinishGrouping, SIGNAL( triggered() ), this, SLOT( groupSymbolsAction() ) );
actnFinishGrouping->setVisible( false );
groupMenu->addAction( actnFinishGrouping );
groupMenu->addAction( actnEditSmartGroup ); groupMenu->addAction( actnEditSmartGroup );
btnManageGroups->setMenu( groupMenu ); btnManageGroups->setMenu( groupMenu );
connect( groupSymbols, SIGNAL( triggered() ), this, SLOT( groupSymbolsAction() ) );


connect( searchBox, SIGNAL( textChanged( QString ) ), this, SLOT( filterSymbols( QString ) ) ); connect( searchBox, SIGNAL( textChanged( QString ) ), this, SLOT( filterSymbols( QString ) ) );
tagsLineEdit->installEventFilter( this ); tagsLineEdit->installEventFilter( this );
Expand Down Expand Up @@ -894,6 +897,7 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
if ( category == "groups" || category == "smartgroups" ) if ( category == "groups" || category == "smartgroups" )
{ {
btnAddGroup->setEnabled( true ); btnAddGroup->setEnabled( true );
actnAddGroup->setEnabled( true );
} }
symbolNames = currentItemType() < 3 ? mStyle->symbolNames() : mStyle->colorRampNames(); symbolNames = currentItemType() < 3 ? mStyle->symbolNames() : mStyle->colorRampNames();
} }
Expand All @@ -903,7 +907,9 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
if ( index.parent().data( Qt::UserRole + 1 ) == "smartgroups" ) if ( index.parent().data( Qt::UserRole + 1 ) == "smartgroups" )
{ {
btnAddGroup->setEnabled( false ); btnAddGroup->setEnabled( false );
actnAddGroup->setEnabled( false );
btnRemoveGroup->setEnabled( true ); btnRemoveGroup->setEnabled( true );
actnRemoveGroup->setEnabled( true );
btnManageGroups->setEnabled( true ); btnManageGroups->setEnabled( true );
int groupId = index.data( Qt::UserRole + 1 ).toInt(); int groupId = index.data( Qt::UserRole + 1 ).toInt();
symbolNames = mStyle->symbolsOfSmartgroup( type, groupId ); symbolNames = mStyle->symbolsOfSmartgroup( type, groupId );
Expand Down Expand Up @@ -938,22 +944,26 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
actnEditSmartGroup->setVisible( false ); actnEditSmartGroup->setVisible( false );
actnAddGroup->setVisible( false ); actnAddGroup->setVisible( false );
actnRemoveGroup->setVisible( false ); actnRemoveGroup->setVisible( false );
actnGroupSymbols->setVisible( false );
actnFinishGrouping->setVisible( false );


if ( index.parent().isValid() && ( index.data().toString() != "Ungrouped" ) ) if ( index.parent().isValid() && ( index.data().toString() != "Ungrouped" ) )
{ {
if ( index.parent().data( Qt::UserRole + 1 ).toString() == "smartgroups" ) if ( index.parent().data( Qt::UserRole + 1 ).toString() == "smartgroups" )
{ {
actnEditSmartGroup->setVisible( true ); actnEditSmartGroup->setVisible( !mGrouppingMode );
} }
else else
{ {
actnAddGroup->setVisible( true ); actnAddGroup->setVisible( !mGrouppingMode );
actnGroupSymbols->setVisible( !mGrouppingMode );
actnFinishGrouping->setVisible( mGrouppingMode );
} }
actnRemoveGroup->setVisible( true ); actnRemoveGroup->setVisible( true );
} }
else if ( index.data( Qt::UserRole + 1 ) == "groups" || index.data( Qt::UserRole + 1 ) == "smartgroups" ) else if ( index.data( Qt::UserRole + 1 ) == "groups" || index.data( Qt::UserRole + 1 ) == "smartgroups" )
{ {
actnAddGroup->setVisible( true ); actnAddGroup->setVisible( !mGrouppingMode );
} }
} }


Expand Down Expand Up @@ -1086,12 +1096,12 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()


QStandardItemModel *treeModel = qobject_cast<QStandardItemModel*>( groupTree->model() ); QStandardItemModel *treeModel = qobject_cast<QStandardItemModel*>( groupTree->model() );
QStandardItemModel *model = qobject_cast<QStandardItemModel*>( listItems->model() ); QStandardItemModel *model = qobject_cast<QStandardItemModel*>( listItems->model() );
QAction *senderAction = qobject_cast<QAction*>( sender() );


if ( mGrouppingMode ) if ( mGrouppingMode )
{ {
mGrouppingMode = false; mGrouppingMode = false;
senderAction->setText( tr( "Group symbols" ) ); actnGroupSymbols->setVisible( true );
actnFinishGrouping->setVisible( false );
// disconnect slot which handles regrouping // disconnect slot which handles regrouping
disconnect( model, SIGNAL( itemChanged( QStandardItem* ) ), disconnect( model, SIGNAL( itemChanged( QStandardItem* ) ),
this, SLOT( regrouped( QStandardItem* ) ) ); this, SLOT( regrouped( QStandardItem* ) ) );
Expand Down Expand Up @@ -1127,8 +1137,9 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
return; return;


mGrouppingMode = true; mGrouppingMode = true;
// Change the text menu // Change visibility of actions
senderAction->setText( tr( "Finish grouping" ) ); actnGroupSymbols->setVisible( false );
actnFinishGrouping->setVisible( true );
// Remove all Symbol editing functionalities // Remove all Symbol editing functionalities
disconnect( treeModel, SIGNAL( itemChanged( QStandardItem* ) ), disconnect( treeModel, SIGNAL( itemChanged( QStandardItem* ) ),
this, SLOT( groupRenamed( QStandardItem* ) ) ); this, SLOT( groupRenamed( QStandardItem* ) ) );
Expand Down Expand Up @@ -1283,7 +1294,9 @@ void QgsStyleV2ManagerDialog::enableSymbolInputs( bool enable )
{ {
groupTree->setEnabled( enable ); groupTree->setEnabled( enable );
btnAddGroup->setEnabled( enable ); btnAddGroup->setEnabled( enable );
actnAddGroup->setEnabled( enable );
btnRemoveGroup->setEnabled( enable ); btnRemoveGroup->setEnabled( enable );
actnRemoveGroup->setEnabled( enable );
btnManageGroups->setEnabled( enable || mGrouppingMode ); // always enabled in grouping mode, as it is the only way to leave grouping mode btnManageGroups->setEnabled( enable || mGrouppingMode ); // always enabled in grouping mode, as it is the only way to leave grouping mode
searchBox->setEnabled( enable ); searchBox->setEnabled( enable );
tagsLineEdit->setEnabled( enable ); tagsLineEdit->setEnabled( enable );
Expand All @@ -1293,6 +1306,7 @@ void QgsStyleV2ManagerDialog::enableGroupInputs( bool enable )
{ {
btnAddGroup->setEnabled( enable ); btnAddGroup->setEnabled( enable );
btnRemoveGroup->setEnabled( enable ); btnRemoveGroup->setEnabled( enable );
actnRemoveGroup->setEnabled( enable );
btnManageGroups->setEnabled( enable || mGrouppingMode ); // always enabled in grouping mode, as it is the only way to leave grouping mode btnManageGroups->setEnabled( enable || mGrouppingMode ); // always enabled in grouping mode, as it is the only way to leave grouping mode
} }


Expand Down Expand Up @@ -1344,7 +1358,7 @@ void QgsStyleV2ManagerDialog::grouptreeContextMenu( const QPoint& point )
QModelIndex index = groupTree->indexAt( point ); QModelIndex index = groupTree->indexAt( point );
QgsDebugMsg( "Now you clicked: " + index.data().toString() ); QgsDebugMsg( "Now you clicked: " + index.data().toString() );


if ( index.isValid() ) if ( index.isValid() && !mGrouppingMode )
mGroupTreeContextMenu->popup( globalPos ); mGroupTreeContextMenu->popup( globalPos );
} }


Expand Down
16 changes: 16 additions & 0 deletions src/ui/qgsstylev2managerdialogbase.ui
Expand Up @@ -484,6 +484,22 @@ QMenu::item:selected { background-color: gray; } */
<string>Remove group</string> <string>Remove group</string>
</property> </property>
</action> </action>
<action name="actnGroupSymbols">
<property name="text">
<string>Group symbols</string>
</property>
</action>
<action name="actnFinishGrouping">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Finish grouping</string>
</property>
<property name="visible">
<bool>true</bool>
</property>
</action>
<action name="actnExportAsPNG"> <action name="actnExportAsPNG">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
Expand Down

0 comments on commit 4d2d001

Please sign in to comment.