mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Merge pull request #2638 from SebDieBln/FixStyleManagerUI
Fix some UI issues in style manager
This commit is contained in:
commit
9d63022e4e
@ -127,6 +127,8 @@ class QgsStyleV2 : QObject
|
||||
int symbolId( const QString& name );
|
||||
//! return the DB id for the given group name
|
||||
int groupId( const QString& group );
|
||||
//! return the group name for the given DB id
|
||||
QString groupName( int groupId ) const;
|
||||
//! return the DB id for the given tag name
|
||||
int tagId( const QString& tag );
|
||||
//! return the DB id for the given smartgroup name
|
||||
@ -135,6 +137,9 @@ class QgsStyleV2 : QObject
|
||||
//! return the all the groups in the style
|
||||
QStringList groupNames();
|
||||
|
||||
//! return the ids of all the groups in the style
|
||||
QList<int> groupIds() const;
|
||||
|
||||
//! returns the symbolnames of a given groupid
|
||||
/*!
|
||||
* \param type is either SymbolEntity or ColorampEntity
|
||||
@ -270,6 +275,9 @@ class QgsStyleV2 : QObject
|
||||
//! gets the id from the table for the given name from the database, 0 if not found
|
||||
int getId( const QString& table, const QString& name );
|
||||
|
||||
//! gets the name from the table for the given id from the database, empty if not found
|
||||
QString getName( const QString& table, int id ) const;
|
||||
|
||||
//! updates the properties of an existing symbol/colorramp
|
||||
/*!
|
||||
* \note This should not be called separately, only called through addSymbol or addColorRamp
|
||||
|
@ -55,6 +55,9 @@ class QgsStyleV2ManagerDialog : QDialog
|
||||
//! Perform symbol specific tasks when selected
|
||||
void symbolSelected( const QModelIndex& );
|
||||
|
||||
//! Perform tasks when the selected symbols change
|
||||
void selectedSymbolsChanged( const QItemSelection& selected, const QItemSelection& deselected );
|
||||
|
||||
//! Context menu for the groupTree
|
||||
void grouptreeContextMenu( const QPoint& );
|
||||
|
||||
@ -63,6 +66,7 @@ class QgsStyleV2ManagerDialog : QDialog
|
||||
|
||||
protected slots:
|
||||
bool addColorRamp( QAction* action );
|
||||
void groupSelectedSymbols();
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -475,6 +475,20 @@ QStringList QgsStyleV2::groupNames()
|
||||
return groupNames;
|
||||
}
|
||||
|
||||
QList<int> QgsStyleV2::groupIds() const
|
||||
{
|
||||
QList<int> groupIds;
|
||||
sqlite3_stmt *ppStmt;
|
||||
const char *query = "SELECT * FROM symgroup";
|
||||
int nError = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, nullptr );
|
||||
while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
|
||||
{
|
||||
groupIds << QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, SymgroupId ) ) ).toInt();
|
||||
}
|
||||
sqlite3_finalize( ppStmt );
|
||||
return groupIds;
|
||||
}
|
||||
|
||||
QgsSymbolGroupMap QgsStyleV2::childGroupNames( const QString& parent )
|
||||
{
|
||||
// get the name list from the sqlite database and return as a QStringList
|
||||
@ -947,6 +961,24 @@ int QgsStyleV2::getId( const QString& table, const QString& name )
|
||||
return id;
|
||||
}
|
||||
|
||||
QString QgsStyleV2::getName( const QString& table, int id ) const
|
||||
{
|
||||
char *query = sqlite3_mprintf( "SELECT name FROM %q WHERE id='%q'", table.toUtf8().constData(), QString::number( id ).toUtf8().constData() );
|
||||
|
||||
sqlite3_stmt *ppStmt;
|
||||
int nErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, nullptr );
|
||||
|
||||
QString name;
|
||||
if ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
|
||||
{
|
||||
name = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, 0 ) ) );
|
||||
}
|
||||
|
||||
sqlite3_finalize( ppStmt );
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
int QgsStyleV2::symbolId( const QString& name )
|
||||
{
|
||||
return getId( "symbol", name );
|
||||
@ -962,6 +994,11 @@ int QgsStyleV2::groupId( const QString& name )
|
||||
return getId( "symgroup", name );
|
||||
}
|
||||
|
||||
QString QgsStyleV2::groupName( int groupId ) const
|
||||
{
|
||||
return getName( "symgroup", groupId );
|
||||
}
|
||||
|
||||
int QgsStyleV2::tagId( const QString& name )
|
||||
{
|
||||
return getId( "tag", name );
|
||||
|
@ -190,6 +190,8 @@ class CORE_EXPORT QgsStyleV2 : public QObject
|
||||
int symbolId( const QString& name );
|
||||
//! return the DB id for the given group name
|
||||
int groupId( const QString& group );
|
||||
//! return the group name for the given DB id
|
||||
QString groupName( int groupId ) const;
|
||||
//! return the DB id for the given tag name
|
||||
int tagId( const QString& tag );
|
||||
//! return the DB id for the given smartgroup name
|
||||
@ -198,6 +200,9 @@ class CORE_EXPORT QgsStyleV2 : public QObject
|
||||
//! return the all the groups in the style
|
||||
QStringList groupNames();
|
||||
|
||||
//! return the ids of all the groups in the style
|
||||
QList<int> groupIds() const;
|
||||
|
||||
//! returns the symbolnames of a given groupid
|
||||
/*!
|
||||
* \param type is either SymbolEntity or ColorampEntity
|
||||
@ -344,6 +349,9 @@ class CORE_EXPORT QgsStyleV2 : public QObject
|
||||
//! gets the id from the table for the given name from the database, 0 if not found
|
||||
int getId( const QString& table, const QString& name );
|
||||
|
||||
//! gets the name from the table for the given id from the database, empty if not found
|
||||
QString getName( const QString& table, int id ) const;
|
||||
|
||||
//! updates the properties of an existing symbol/colorramp
|
||||
/*!
|
||||
* \note This should not be called separately, only called through addSymbol or addColorRamp
|
||||
|
@ -51,6 +51,8 @@ QgsStyleV2ExportImportDialog::QgsStyleV2ExportImportDialog( QgsStyleV2* style, Q
|
||||
QStandardItemModel* model = new QStandardItemModel( listItems );
|
||||
|
||||
listItems->setModel( model );
|
||||
connect( listItems->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ),
|
||||
this, SLOT( selectionChanged( const QItemSelection&, const QItemSelection& ) ) );
|
||||
|
||||
mTempStyle = new QgsStyleV2();
|
||||
// TODO validate
|
||||
@ -63,7 +65,7 @@ QgsStyleV2ExportImportDialog::QgsStyleV2ExportImportDialog( QgsStyleV2* style, Q
|
||||
|
||||
if ( mDialogMode == Import )
|
||||
{
|
||||
setWindowTitle( tr( "Import style(s)" ) );
|
||||
setWindowTitle( tr( "Import symbol(s)" ) );
|
||||
// populate the import types
|
||||
importTypeCombo->addItem( tr( "file specified below" ), QVariant( "file" ) );
|
||||
// importTypeCombo->addItem( "official QGIS repo online", QVariant( "official" ) );
|
||||
@ -85,7 +87,7 @@ QgsStyleV2ExportImportDialog::QgsStyleV2ExportImportDialog( QgsStyleV2* style, Q
|
||||
}
|
||||
else
|
||||
{
|
||||
setWindowTitle( tr( "Export style(s)" ) );
|
||||
setWindowTitle( tr( "Export symbol(s)" ) );
|
||||
// hide import specific controls when exporting
|
||||
btnBrowse->setHidden( true );
|
||||
fromLabel->setHidden( true );
|
||||
@ -109,6 +111,7 @@ QgsStyleV2ExportImportDialog::QgsStyleV2ExportImportDialog( QgsStyleV2* style, Q
|
||||
// use Ok button for starting import and export operations
|
||||
disconnect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
|
||||
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( doExportImport() ) );
|
||||
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
|
||||
}
|
||||
|
||||
void QgsStyleV2ExportImportDialog::doExportImport()
|
||||
@ -594,3 +597,11 @@ void QgsStyleV2ExportImportDialog::downloadCanceled()
|
||||
mTempFile->remove();
|
||||
mFileName = "";
|
||||
}
|
||||
|
||||
void QgsStyleV2ExportImportDialog::selectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
|
||||
{
|
||||
Q_UNUSED( selected );
|
||||
Q_UNUSED( deselected );
|
||||
bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
|
||||
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( nothingSelected );
|
||||
}
|
||||
|
@ -100,6 +100,7 @@ class GUI_EXPORT QgsStyleV2ExportImportDialog : public QDialog, private Ui::QgsS
|
||||
void fileReadyRead();
|
||||
void updateProgress( qint64, qint64 );
|
||||
void downloadCanceled();
|
||||
void selectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
|
||||
|
||||
private:
|
||||
void downloadStyleXML( const QUrl& url );
|
||||
|
@ -49,6 +49,7 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
|
||||
#endif
|
||||
|
||||
QSettings settings;
|
||||
|
||||
restoreGeometry( settings.value( "/Windows/StyleV2Manager/geometry" ).toByteArray() );
|
||||
mSplitter->setSizes( QList<int>() << 170 << 540 );
|
||||
mSplitter->restoreState( settings.value( "/Windows/StyleV2Manager/splitter" ).toByteArray() );
|
||||
@ -61,20 +62,23 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
|
||||
connect( listItems, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( editItem() ) );
|
||||
|
||||
connect( btnAddItem, SIGNAL( clicked() ), this, SLOT( addItem() ) );
|
||||
connect( btnEditItem, SIGNAL( clicked() ), this, SLOT( editItem() ) );
|
||||
connect( btnRemoveItem, SIGNAL( clicked() ), this, SLOT( removeItem() ) );
|
||||
connect( actnEditItem, SIGNAL( triggered( bool ) ), this, SLOT( editItem() ) );
|
||||
connect( actnRemoveItem, SIGNAL( triggered( bool ) ), this, SLOT( removeItem() ) );
|
||||
|
||||
QMenu *shareMenu = new QMenu( tr( "Share Menu" ), this );
|
||||
QAction *exportAsPNGAction = shareMenu->addAction( tr( "Export as PNG" ) );
|
||||
QAction *exportAsSVGAction = shareMenu->addAction( tr( "Export as SVG" ) );
|
||||
QAction *exportAction = shareMenu->addAction( tr( "Export" ) );
|
||||
QAction *importAction = shareMenu->addAction( tr( "Import" ) );
|
||||
exportAsPNGAction->setIcon( QIcon( QgsApplication::iconPath( "mActionSharingExport.svg" ) ) );
|
||||
exportAsSVGAction->setIcon( QIcon( QgsApplication::iconPath( "mActionSharingExport.svg" ) ) );
|
||||
btnRemoveItem->setDefaultAction( actnRemoveItem );
|
||||
btnEditItem->setDefaultAction( actnEditItem );
|
||||
|
||||
QMenu *shareMenu = new QMenu( tr( "Share menu" ), this );
|
||||
shareMenu->addAction( actnExportAsPNG );
|
||||
shareMenu->addAction( actnExportAsSVG );
|
||||
QAction *exportAction = new QAction( tr( "Export..." ), this );
|
||||
shareMenu->addAction( exportAction );
|
||||
QAction *importAction = new QAction( tr( "Import..." ), this );
|
||||
shareMenu->addAction( importAction );
|
||||
exportAction->setIcon( QIcon( QgsApplication::iconPath( "mActionSharingExport.svg" ) ) );
|
||||
importAction->setIcon( QIcon( QgsApplication::iconPath( "mActionSharingImport.svg" ) ) );
|
||||
connect( exportAsPNGAction, SIGNAL( triggered() ), this, SLOT( exportItemsPNG() ) );
|
||||
connect( exportAsSVGAction, SIGNAL( triggered() ), this, SLOT( exportItemsSVG() ) );
|
||||
connect( actnExportAsPNG, SIGNAL( triggered() ), this, SLOT( exportItemsPNG() ) );
|
||||
connect( actnExportAsSVG, SIGNAL( triggered() ), this, SLOT( exportItemsSVG() ) );
|
||||
connect( exportAction, SIGNAL( triggered() ), this, SLOT( exportItems() ) );
|
||||
connect( importAction, SIGNAL( triggered() ), this, SLOT( importItems() ) );
|
||||
btnShare->setMenu( shareMenu );
|
||||
@ -89,6 +93,8 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
|
||||
connect( model, SIGNAL( itemChanged( QStandardItem* ) ), this, SLOT( itemChanged( QStandardItem* ) ) );
|
||||
connect( listItems->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ),
|
||||
this, SLOT( symbolSelected( const QModelIndex& ) ) );
|
||||
connect( listItems->selectionModel(), SIGNAL( selectionChanged( const QItemSelection, const QItemSelection ) ),
|
||||
this, SLOT( selectedSymbolsChanged( const QItemSelection&, const QItemSelection& ) ) );
|
||||
|
||||
populateTypes();
|
||||
|
||||
@ -101,17 +107,14 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
|
||||
connect( groupModel, SIGNAL( itemChanged( QStandardItem* ) ),
|
||||
this, SLOT( groupRenamed( QStandardItem* ) ) );
|
||||
|
||||
QMenu *groupMenu = new QMenu( tr( "Group Actions" ), this );
|
||||
QAction *groupSymbols = groupMenu->addAction( tr( "Group Symbols" ) );
|
||||
QAction *editSmartgroup = groupMenu->addAction( tr( "Edit Smart Group" ) );
|
||||
QMenu *groupMenu = new QMenu( tr( "Group actions" ), this );
|
||||
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 );
|
||||
btnManageGroups->setMenu( groupMenu );
|
||||
connect( groupSymbols, SIGNAL( triggered() ), this, SLOT( groupSymbolsAction() ) );
|
||||
connect( editSmartgroup, SIGNAL( triggered() ), this, SLOT( editSmartgroupAction() ) );
|
||||
|
||||
connect( btnAddGroup, SIGNAL( clicked() ), this, SLOT( addGroup() ) );
|
||||
connect( btnRemoveGroup, SIGNAL( clicked() ), this, SLOT( removeGroup() ) );
|
||||
|
||||
on_tabItemType_currentChanged( 0 );
|
||||
|
||||
connect( searchBox, SIGNAL( textChanged( QString ) ), this, SLOT( filterSymbols( QString ) ) );
|
||||
tagsLineEdit->installEventFilter( this );
|
||||
@ -126,6 +129,42 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
|
||||
connect( listItems, SIGNAL( customContextMenuRequested( const QPoint& ) ),
|
||||
this, SLOT( listitemsContextMenu( const QPoint& ) ) );
|
||||
|
||||
// Menu for the "Add item" toolbutton when in colorramp mode
|
||||
QStringList rampTypes;
|
||||
rampTypes << tr( "Gradient" ) << tr( "Random" ) << tr( "ColorBrewer" );
|
||||
rampTypes << tr( "cpt-city" ); // todo, only for rasters?
|
||||
mMenuBtnAddItemColorRamp = new QMenu( this );
|
||||
Q_FOREACH ( const QString& rampType, rampTypes )
|
||||
mMenuBtnAddItemColorRamp->addAction( new QAction( rampType, this ) );
|
||||
connect( mMenuBtnAddItemColorRamp, SIGNAL( triggered( QAction* ) ),
|
||||
this, SLOT( addColorRamp( QAction* ) ) );
|
||||
|
||||
// Context menu for symbols/colorramps. The menu entries for every group are created when displaying the menu.
|
||||
mGroupMenu = new QMenu( this );
|
||||
mGroupListMenu = new QMenu( mGroupMenu );
|
||||
mGroupListMenu->setTitle( tr( "Apply Group" ) );
|
||||
mGroupListMenu->setEnabled( false );
|
||||
mGroupMenu->addMenu( mGroupListMenu );
|
||||
actnUngroup->setData( 0 );
|
||||
connect( actnUngroup, SIGNAL( triggered( bool ) ), this, SLOT( groupSelectedSymbols() ) );
|
||||
mGroupMenu->addAction( actnUngroup );
|
||||
mGroupMenu->addSeparator()->setParent( this );
|
||||
mGroupMenu->addAction( actnRemoveItem );
|
||||
mGroupMenu->addAction( actnEditItem );
|
||||
mGroupMenu->addSeparator()->setParent( this );
|
||||
mGroupMenu->addAction( actnExportAsPNG );
|
||||
mGroupMenu->addAction( actnExportAsSVG );
|
||||
|
||||
// Context menu for the group tree
|
||||
mGroupTreeContextMenu = new QMenu( this );
|
||||
connect( actnEditSmartGroup, SIGNAL( triggered( bool ) ), this, SLOT( editSmartgroupAction() ) );
|
||||
mGroupTreeContextMenu->addAction( actnEditSmartGroup );
|
||||
connect( actnAddGroup, SIGNAL( triggered( bool ) ), this, SLOT( addGroup() ) );
|
||||
mGroupTreeContextMenu->addAction( actnAddGroup );
|
||||
connect( actnRemoveGroup, SIGNAL( triggered( bool ) ), this, SLOT( removeGroup() ) );
|
||||
mGroupTreeContextMenu->addAction( actnRemoveGroup );
|
||||
|
||||
on_tabItemType_currentChanged( 0 );
|
||||
}
|
||||
|
||||
void QgsStyleV2ManagerDialog::onFinished()
|
||||
@ -183,36 +222,11 @@ void QgsStyleV2ManagerDialog::populateTypes()
|
||||
|
||||
void QgsStyleV2ManagerDialog::on_tabItemType_currentChanged( int )
|
||||
{
|
||||
// when in Color Ramp tab, add menu to add item button
|
||||
if ( currentItemType() == 3 )
|
||||
{
|
||||
btnShare->menu()->actions().at( 0 )->setVisible( false );
|
||||
btnShare->menu()->actions().at( 1 )->setVisible( false );
|
||||
|
||||
QStringList rampTypes;
|
||||
rampTypes << tr( "Gradient" ) << tr( "Random" ) << tr( "ColorBrewer" );
|
||||
rampTypes << tr( "cpt-city" ); // todo, only for rasters?
|
||||
QMenu* menu = new QMenu( btnAddItem );
|
||||
Q_FOREACH ( const QString& rampType, rampTypes )
|
||||
{
|
||||
menu->addAction( rampType );
|
||||
}
|
||||
btnAddItem->setMenu( menu );
|
||||
connect( menu, SIGNAL( triggered( QAction* ) ),
|
||||
this, SLOT( addColorRamp( QAction* ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
btnShare->menu()->actions().at( 0 )->setVisible( true );
|
||||
btnShare->menu()->actions().at( 1 )->setVisible( true );
|
||||
|
||||
if ( btnAddItem->menu() )
|
||||
{
|
||||
disconnect( btnAddItem->menu(), SIGNAL( triggered( QAction* ) ),
|
||||
this, SLOT( addColorRamp( QAction* ) ) );
|
||||
btnAddItem->setMenu( nullptr );
|
||||
}
|
||||
}
|
||||
// when in Color Ramp tab, add menu to add item button and hide "Export symbols as PNG/SVG"
|
||||
bool flag = currentItemType() != 3;
|
||||
btnAddItem->setMenu( flag ? nullptr : mMenuBtnAddItemColorRamp );
|
||||
actnExportAsPNG->setVisible( flag );
|
||||
actnExportAsSVG->setVisible( flag );
|
||||
|
||||
// set icon and grid size, depending on type
|
||||
if ( currentItemType() == 1 || currentItemType() == 3 )
|
||||
@ -263,6 +277,8 @@ void QgsStyleV2ManagerDialog::populateSymbols( const QStringList& symbolNames, b
|
||||
}
|
||||
delete symbol;
|
||||
}
|
||||
selectedSymbolsChanged( QItemSelection(), QItemSelection() );
|
||||
symbolSelected( listItems->currentIndex() );
|
||||
}
|
||||
|
||||
|
||||
@ -697,6 +713,12 @@ void QgsStyleV2ManagerDialog::removeItem()
|
||||
bool QgsStyleV2ManagerDialog::removeSymbol()
|
||||
{
|
||||
QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
|
||||
if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm removal" ),
|
||||
QString( tr( "Do you really want to remove %n symbol(s)?", nullptr, indexes.count() ) ),
|
||||
QMessageBox::Yes,
|
||||
QMessageBox::No ) )
|
||||
return false;
|
||||
|
||||
Q_FOREACH ( const QModelIndex& index, indexes )
|
||||
{
|
||||
QString symbolName = index.data().toString();
|
||||
@ -713,6 +735,11 @@ bool QgsStyleV2ManagerDialog::removeColorRamp()
|
||||
QString rampName = currentItemName();
|
||||
if ( rampName.isEmpty() )
|
||||
return false;
|
||||
if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm removal" ),
|
||||
QString( tr( "Do you really want to remove the colorramp '%1'?" ) ).arg( rampName ),
|
||||
QMessageBox::Yes,
|
||||
QMessageBox::No ) )
|
||||
return false;
|
||||
|
||||
mStyle->removeColorRamp( rampName );
|
||||
mModified = true;
|
||||
@ -881,6 +908,7 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
|
||||
if ( category == "groups" || category == "smartgroups" )
|
||||
{
|
||||
btnAddGroup->setEnabled( true );
|
||||
actnAddGroup->setEnabled( true );
|
||||
}
|
||||
symbolNames = currentItemType() < 3 ? mStyle->symbolNames() : mStyle->colorRampNames();
|
||||
}
|
||||
@ -890,7 +918,9 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
|
||||
if ( index.parent().data( Qt::UserRole + 1 ) == "smartgroups" )
|
||||
{
|
||||
btnAddGroup->setEnabled( false );
|
||||
actnAddGroup->setEnabled( false );
|
||||
btnRemoveGroup->setEnabled( true );
|
||||
actnRemoveGroup->setEnabled( true );
|
||||
btnManageGroups->setEnabled( true );
|
||||
int groupId = index.data( Qt::UserRole + 1 ).toInt();
|
||||
symbolNames = mStyle->symbolsOfSmartgroup( type, groupId );
|
||||
@ -921,6 +951,31 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
|
||||
}
|
||||
if ( mGrouppingMode )
|
||||
setSymbolsChecked( groupSymbols );
|
||||
|
||||
actnEditSmartGroup->setVisible( false );
|
||||
actnAddGroup->setVisible( false );
|
||||
actnRemoveGroup->setVisible( false );
|
||||
actnGroupSymbols->setVisible( false );
|
||||
actnFinishGrouping->setVisible( false );
|
||||
|
||||
if ( index.parent().isValid() && ( index.data().toString() != "Ungrouped" ) )
|
||||
{
|
||||
if ( index.parent().data( Qt::UserRole + 1 ).toString() == "smartgroups" )
|
||||
{
|
||||
actnEditSmartGroup->setVisible( !mGrouppingMode );
|
||||
}
|
||||
else
|
||||
{
|
||||
actnAddGroup->setVisible( !mGrouppingMode );
|
||||
actnGroupSymbols->setVisible( !mGrouppingMode );
|
||||
actnFinishGrouping->setVisible( mGrouppingMode );
|
||||
}
|
||||
actnRemoveGroup->setVisible( true );
|
||||
}
|
||||
else if ( index.data( Qt::UserRole + 1 ) == "groups" || index.data( Qt::UserRole + 1 ) == "smartgroups" )
|
||||
{
|
||||
actnAddGroup->setVisible( !mGrouppingMode );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsStyleV2ManagerDialog::addGroup()
|
||||
@ -1052,12 +1107,12 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
|
||||
|
||||
QStandardItemModel *treeModel = qobject_cast<QStandardItemModel*>( groupTree->model() );
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel*>( listItems->model() );
|
||||
QAction *senderAction = qobject_cast<QAction*>( sender() );
|
||||
|
||||
if ( mGrouppingMode )
|
||||
{
|
||||
mGrouppingMode = false;
|
||||
senderAction->setText( tr( "Group Symbols" ) );
|
||||
actnGroupSymbols->setVisible( true );
|
||||
actnFinishGrouping->setVisible( false );
|
||||
// disconnect slot which handles regrouping
|
||||
disconnect( model, SIGNAL( itemChanged( QStandardItem* ) ),
|
||||
this, SLOT( regrouped( QStandardItem* ) ) );
|
||||
@ -1093,8 +1148,9 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
|
||||
return;
|
||||
|
||||
mGrouppingMode = true;
|
||||
// Change the text menu
|
||||
senderAction->setText( tr( "Finish Grouping" ) );
|
||||
// Change visibility of actions
|
||||
actnGroupSymbols->setVisible( false );
|
||||
actnFinishGrouping->setVisible( true );
|
||||
// Remove all Symbol editing functionalities
|
||||
disconnect( treeModel, SIGNAL( itemChanged( QStandardItem* ) ),
|
||||
this, SLOT( groupRenamed( QStandardItem* ) ) );
|
||||
@ -1222,17 +1278,36 @@ void QgsStyleV2ManagerDialog::symbolSelected( const QModelIndex& index )
|
||||
{
|
||||
// Populate the tags for the symbol
|
||||
tagsLineEdit->clear();
|
||||
QStandardItem *item = static_cast<QStandardItemModel*>( listItems->model() )->itemFromIndex( index );
|
||||
QgsStyleV2::StyleEntity type = ( currentItemType() < 3 ) ? QgsStyleV2::SymbolEntity : QgsStyleV2::ColorrampEntity;
|
||||
mTagList = mStyle->tagsOfSymbol( type, item->data().toString() );
|
||||
tagsLineEdit->setText( mTagList.join( "," ) );
|
||||
if ( index.isValid() )
|
||||
{
|
||||
QStandardItem *item = static_cast<QStandardItemModel*>( listItems->model() )->itemFromIndex( index );
|
||||
QgsStyleV2::StyleEntity type = ( currentItemType() < 3 ) ? QgsStyleV2::SymbolEntity : QgsStyleV2::ColorrampEntity;
|
||||
mTagList = mStyle->tagsOfSymbol( type, item->data().toString() );
|
||||
tagsLineEdit->setText( mTagList.join( "," ) );
|
||||
}
|
||||
|
||||
actnEditItem->setEnabled( index.isValid() && !mGrouppingMode );
|
||||
}
|
||||
|
||||
void QgsStyleV2ManagerDialog::selectedSymbolsChanged( const QItemSelection& selected, const QItemSelection& deselected )
|
||||
{
|
||||
Q_UNUSED( selected );
|
||||
Q_UNUSED( deselected );
|
||||
bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
|
||||
actnRemoveItem->setDisabled( nothingSelected );
|
||||
mGroupListMenu->setDisabled( nothingSelected );
|
||||
actnUngroup->setDisabled( nothingSelected );
|
||||
actnExportAsPNG->setDisabled( nothingSelected );
|
||||
actnExportAsSVG->setDisabled( nothingSelected );
|
||||
}
|
||||
|
||||
void QgsStyleV2ManagerDialog::enableSymbolInputs( bool enable )
|
||||
{
|
||||
groupTree->setEnabled( enable );
|
||||
btnAddGroup->setEnabled( enable );
|
||||
actnAddGroup->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
|
||||
searchBox->setEnabled( enable );
|
||||
tagsLineEdit->setEnabled( enable );
|
||||
@ -1242,6 +1317,7 @@ void QgsStyleV2ManagerDialog::enableGroupInputs( bool enable )
|
||||
{
|
||||
btnAddGroup->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
|
||||
}
|
||||
|
||||
@ -1281,6 +1357,9 @@ void QgsStyleV2ManagerDialog::enableItemsForGroupingMode( bool enable )
|
||||
w->setEnabled( enable );
|
||||
}
|
||||
|
||||
// The actions
|
||||
actnRemoveItem->setEnabled( enable );
|
||||
actnEditItem->setEnabled( enable );
|
||||
}
|
||||
|
||||
void QgsStyleV2ManagerDialog::grouptreeContextMenu( const QPoint& point )
|
||||
@ -1290,56 +1369,33 @@ void QgsStyleV2ManagerDialog::grouptreeContextMenu( const QPoint& point )
|
||||
QModelIndex index = groupTree->indexAt( point );
|
||||
QgsDebugMsg( "Now you clicked: " + index.data().toString() );
|
||||
|
||||
QMenu groupMenu;
|
||||
|
||||
if ( index.parent().isValid() && ( index.data().toString() != "Ungrouped" ) )
|
||||
{
|
||||
if ( index.parent().data( Qt::UserRole + 1 ).toString() == "smartgroups" )
|
||||
{
|
||||
groupMenu.addAction( tr( "Edit Group" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
groupMenu.addAction( tr( "Add Group" ) );
|
||||
}
|
||||
groupMenu.addAction( tr( "Remove Group" ) );
|
||||
}
|
||||
else if ( index.data( Qt::UserRole + 1 ) == "groups" || index.data( Qt::UserRole + 1 ) == "smartgroups" )
|
||||
{
|
||||
groupMenu.addAction( tr( "Add Group" ) );
|
||||
}
|
||||
|
||||
|
||||
QAction* selectedItem = groupMenu.exec( globalPos );
|
||||
|
||||
if ( selectedItem )
|
||||
{
|
||||
if ( selectedItem->text() == tr( "Add Group" ) )
|
||||
addGroup();
|
||||
else if ( selectedItem->text() == tr( "Remove Group" ) )
|
||||
removeGroup();
|
||||
else if ( selectedItem->text() == tr( "Edit Group" ) )
|
||||
editSmartgroupAction();
|
||||
}
|
||||
if ( index.isValid() && !mGrouppingMode )
|
||||
mGroupTreeContextMenu->popup( globalPos );
|
||||
}
|
||||
|
||||
void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
|
||||
{
|
||||
QPoint globalPos = listItems->viewport()->mapToGlobal( point );
|
||||
|
||||
QMenu *groupMenu = new QMenu( this );
|
||||
QMenu *groupList = new QMenu( this );
|
||||
groupList->setTitle( tr( "Apply Group" ) );
|
||||
// Clear all actions and create new actions for every group
|
||||
mGroupListMenu->clear();
|
||||
|
||||
QStringList groups = mStyle->groupNames();
|
||||
Q_FOREACH ( const QString& group, groups )
|
||||
QAction* a;
|
||||
QList<int> groupIds = mStyle->groupIds();
|
||||
Q_FOREACH ( int groupId, groupIds )
|
||||
{
|
||||
groupList->addAction( group );
|
||||
a = new QAction( mStyle->groupName( groupId ), mGroupListMenu );
|
||||
a->setData( groupId );
|
||||
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( groupSelectedSymbols() ) );
|
||||
mGroupListMenu->addAction( a );
|
||||
}
|
||||
groupMenu->addMenu( groupList );
|
||||
groupMenu->addAction( tr( "Un-group" ) );
|
||||
|
||||
QAction* selectedItem = groupMenu->exec( globalPos );
|
||||
mGroupMenu->popup( globalPos );
|
||||
}
|
||||
|
||||
void QgsStyleV2ManagerDialog::groupSelectedSymbols()
|
||||
{
|
||||
QAction* selectedItem = qobject_cast<QAction*>( sender() );
|
||||
|
||||
if ( selectedItem )
|
||||
{
|
||||
@ -1349,11 +1405,7 @@ void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
|
||||
QgsDebugMsg( "unknow entity type" );
|
||||
return;
|
||||
}
|
||||
int groupId = 0;
|
||||
if ( selectedItem->text() != tr( "Un-group" ) )
|
||||
{
|
||||
groupId = mStyle->groupId( selectedItem->text() );
|
||||
}
|
||||
int groupId = selectedItem->data().toInt();
|
||||
QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
|
||||
Q_FOREACH ( const QModelIndex& index, indexes )
|
||||
{
|
||||
|
@ -81,6 +81,9 @@ class GUI_EXPORT QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV
|
||||
//! Perform symbol specific tasks when selected
|
||||
void symbolSelected( const QModelIndex& );
|
||||
|
||||
//! Perform tasks when the selected symbols change
|
||||
void selectedSymbolsChanged( const QItemSelection& selected, const QItemSelection& deselected );
|
||||
|
||||
//! Context menu for the groupTree
|
||||
void grouptreeContextMenu( const QPoint& );
|
||||
|
||||
@ -89,6 +92,7 @@ class GUI_EXPORT QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV
|
||||
|
||||
protected slots:
|
||||
bool addColorRamp( QAction* action );
|
||||
void groupSelectedSymbols();
|
||||
|
||||
protected:
|
||||
|
||||
@ -146,6 +150,18 @@ class GUI_EXPORT QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV
|
||||
|
||||
//! space to store symbol tags
|
||||
QStringList mTagList;
|
||||
|
||||
//! Context menu for the symbols/colorramps
|
||||
QMenu *mGroupMenu;
|
||||
|
||||
//! Sub-menu of @c mGroupMenu, dynamically filled to show one entry for every group
|
||||
QMenu *mGroupListMenu;
|
||||
|
||||
//! Context menu for the group tree
|
||||
QMenu* mGroupTreeContextMenu;
|
||||
|
||||
//! Menu for the "Add item" toolbutton when in colorramp mode
|
||||
QMenu* mMenuBtnAddItemColorRamp;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -420,6 +420,116 @@ QMenu::item:selected { background-color: gray; } */
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="actnRemoveItem">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/symbologyRemove.png</normaloff>:/images/themes/default/symbologyRemove.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove item(s)</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove item(s)</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actnEditItem">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mActionProjectProperties.png</normaloff>:/images/themes/default/mActionProjectProperties.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit item...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Edit item</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actnUngroup">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ungroup</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Ungroup</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actnEditSmartGroup">
|
||||
<property name="text">
|
||||
<string>Edit smart group...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actnAddGroup">
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/symbologyAdd.png</normaloff>:/images/themes/default/symbologyAdd.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add group</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actnRemoveGroup">
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/symbologyRemove.png</normaloff>:/images/themes/default/symbologyRemove.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove group</string>
|
||||
</property>
|
||||
</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">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mActionSharingExport.svg</normaloff>:/images/themes/default/mActionSharingExport.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Export selected symbol(s) as PNG...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Export selected symbo(s) as PNG</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actnExportAsSVG">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mActionSharingExport.svg</normaloff>:/images/themes/default/mActionSharingExport.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Export selected symbol(s) as SVG...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Export selected symbol(s) as SVG</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
@ -462,5 +572,37 @@ QMenu::item:selected { background-color: gray; } */
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>btnAddGroup</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>actnAddGroup</receiver>
|
||||
<slot>trigger()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>46</x>
|
||||
<y>362</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>btnRemoveGroup</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>actnRemoveGroup</receiver>
|
||||
<slot>trigger()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>133</x>
|
||||
<y>362</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user