Skip to content

Commit 5e487cf

Browse files
committedNov 16, 2016
[FEATURE] Style management re-work and upgrade
- A new favorite grouping system was added, which the symbols list widget defaults to - The selected tag / smartgroup in the symbols list widget now persists when switching layers (and across sessions) - The symbols list widget will update the tag / smartgroup combo box when users add / rename / remove categories - Users can now directly tag, as well as add to favorites, symbols while saving those to the style database - To streamline style management, groups have been removed and fully replaced by tags - Tags have been integrated into the import/export user interface
1 parent 6727ea7 commit 5e487cf

30 files changed

+1186
-929
lines changed
 

‎doc/api_break.dox

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,11 @@ QgsSvgCache {#qgis_api_break_3_0_QgsSvgCache}
13521352

13531353
- containsParamsV2() was removed. Use containsParamsV3() instead.
13541354

1355+
QgsStyle (renamed from QgsStyleV2) {#qgis_api_break_3_0_QgsStyle}
1356+
----------------------------------
1357+
- All group functions have been removed: group(), addGroup(), groupId(), groupName(), groupNames(), groupIds(), symbolsOfGroup(), getGroupRemoveQuery()
1358+
- The StyleEntity::GroupEntity has been removed
1359+
- The SymgroupTable enum has been removed
13551360

13561361
QgsSymbol (renamed from QgsSymbolV2) {#qgis_api_break_3_0_QgsSymbol}
13571362
------------------------------------

‎python/core/symbology-ng/qgsstyle.sip

Lines changed: 98 additions & 102 deletions
Large diffs are not rendered by default.

‎python/gui/gui.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@
247247
%Include symbology-ng/qgsstyleexportimportdialog.sip
248248
%Include symbology-ng/qgsstylegroupselectiondialog.sip
249249
%Include symbology-ng/qgsstylemanagerdialog.sip
250+
%Include symbology-ng/qgsstylesavedialog.sip
250251
%Include symbology-ng/qgssvgselectorwidget.sip
251252
%Include symbology-ng/qgssymbollayerwidget.sip
252253
%Include symbology-ng/qgssymbollevelsdialog.sip

‎python/gui/symbology-ng/qgsstyleexportimportdialog.sip

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ class QgsStyleExportImportDialog : QDialog
4141
*/
4242
void clearSelection();
4343
/**
44-
* Select the symbols belonging to the given group
45-
* @param groupName the name of the group to be selected
44+
* Select the symbols belonging to the given tag
45+
* @param tagName the name of the tag to be selected
4646
*/
47-
void selectGroup( const QString& groupName );
47+
void selectTag( const QString& tagName );
4848
/**
49-
* Deselect the symbols belonging to the given group
50-
* @param groupName the name of the group to be deselected
49+
* Deselect the symbols belonging to the given tag
50+
* @param tagName the name of the tag to be deselected
5151
*/
52-
void deselectGroup( const QString& groupName );
52+
void deselectTag( const QString& tagName );
5353
/**
5454
* @brief selectSmartgroup selects all symbols from a smart group
5555
* @param groupName

‎python/gui/symbology-ng/qgsstylegroupselectiondialog.sip

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class QgsStyleGroupSelectionDialog : public QDialog, private Ui::SymbolsGroupSel
2828
void setBold( QStandardItem *item );
2929

3030
signals:
31-
//! group with groupName has been selected
32-
void groupSelected( const QString& groupName );
33-
//! group with groupName has been deselected
34-
void groupDeselected( const QString& groupName );
31+
//! tag with tagName has been selected
32+
void tagSelected( const QString& tagName );
33+
//! tag with tagName has been deselected
34+
void tagDeselected( const QString& tagName );
3535
//! smartgroup with groupName has been selected
3636
void smartgroupSelected( const QString& groupName );
3737
//! smart group with groupName has been deselected

‎python/gui/symbology-ng/qgsstylemanagerdialog.sip

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class QgsStyleManagerDialog : QDialog
3737
void addGroup();
3838
void removeGroup();
3939

40-
//! carryout symbol grouping using check boxes
41-
void groupSymbolsAction();
40+
//! carry out symbol tagging using check boxes
41+
void tagSymbolsAction();
4242

4343
//! edit the selected smart group
4444
void editSmartgroupAction();
@@ -49,9 +49,6 @@ class QgsStyleManagerDialog : QDialog
4949
//! filter the symbols based on input search term
5050
void filterSymbols( const QString& );
5151

52-
//! Listen to tag changes
53-
void tagsChanged();
54-
5552
//! Perform symbol specific tasks when selected
5653
void symbolSelected( const QModelIndex& );
5754

@@ -66,7 +63,14 @@ class QgsStyleManagerDialog : QDialog
6663

6764
protected slots:
6865
bool addColorRamp( QAction* action );
69-
void groupSelectedSymbols();
66+
//! Add selected symbols to favorites
67+
void addFavoriteSelectedSymbols();
68+
//! Remove selected symbols from favorites
69+
void removeFavoriteSelectedSymbols();
70+
//! Tag selected symbols using menu item selection
71+
void tagSelectedSymbols();
72+
//! Remove all tags from selected symbols
73+
void detagSelectedSymbols();
7074

7175
protected:
7276

@@ -75,8 +79,6 @@ class QgsStyleManagerDialog : QDialog
7579

7680
//! populate the groups
7781
void populateGroups();
78-
//! build the groups tree
79-
void buildGroupTree( QStandardItem* &parent );
8082
//! to set symbols checked when in editing mode
8183
void setSymbolsChecked( const QStringList& );
8284

@@ -107,9 +109,6 @@ class QgsStyleManagerDialog : QDialog
107109
//! Enables or diables the groupTree items for grouping mode
108110
void enableItemsForGroupingMode( bool );
109111

110-
//! Event filter to capture tagsLineEdit out of focus
111-
bool eventFilter( QObject*, QEvent* );
112-
113112
//! sets the text of the item with bold font
114113
void setBold( QStandardItem* );
115114
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class QgsStyleSaveDialog : QDialog
2+
{
3+
%TypeHeaderCode
4+
#include <qgsstylesavedialog.h>
5+
%End
6+
7+
public:
8+
/** Constructor for QgsSymbolSaveDialog
9+
* @param parent parent widget
10+
* @param type the QgsStyle entity type being saved
11+
*/
12+
QgsStyleSaveDialog( QWidget* parent /TransferThis/ = NULL, QgsStyle::StyleEntity type = QgsStyle::SymbolEntity );
13+
14+
//! returns the text value of the name element
15+
QString name() const;
16+
17+
//! returns the text value of the tags element
18+
QString tags() const;
19+
20+
//! returns whether the favorite element is checked
21+
bool isFavorite() const;
22+
};

‎python/gui/symbology-ng/qgssymbolslistwidget.sip

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ class QgsSymbolsListWidget : QWidget
3737
void on_mSymbolUnitWidget_changed();
3838
void on_mTransparencySlider_valueChanged( int value );
3939

40+
//! Pupulates the groups combo box with available tags and smartgroups
41+
void populateGroups();
4042
void on_groupsCombo_currentIndexChanged( int index );
41-
void on_groupsCombo_editTextChanged( const QString &text );
4243

4344
void openStyleManager();
4445
void clipFeaturesToggled( bool checked );

‎resources/symbology-ng-style.db

20 KB
Binary file not shown.

‎resources/symbology-ng-style.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@
838838
<prop k="width_unit" v="MM"/>
839839
</layer>
840840
</symbol>
841-
<symbol alpha="1" type="marker" name="airport">
841+
<symbol alpha="1" type="marker" name="airport" favorite="1">
842842
<layer pass="0" class="SvgMarker" locked="0">
843843
<prop k="angle" v="0"/>
844844
<prop k="fill" v="#000000"/>

‎scripts/symbol_xml2db.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
"id INTEGER PRIMARY KEY,"\
3333
"name TEXT UNIQUE,"\
3434
"xml TEXT,"\
35-
"groupid INTEGER)"
35+
"favorite INTEGER)"
3636

3737
_colorramp = "CREATE TABLE colorramp("\
3838
"id INTEGER PRIMARY KEY,"\
3939
"name TEXT UNIQUE,"\
4040
"xml TEXT,"\
41-
"groupid INTEGER)"
41+
"favorite INTEGER)"
4242

4343
_tag = "CREATE TABLE tag("\
4444
"id INTEGER PRIMARY KEY,"\
@@ -48,57 +48,60 @@
4848
"tag_id INTEGER NOT NULL,"\
4949
"symbol_id INTEGER)"
5050

51-
_symgroup = "CREATE TABLE symgroup("\
52-
"id INTEGER PRIMARY KEY,"\
53-
"name TEXT,"\
54-
"parent INTEGER)"
51+
_ctagmap = "CREATE TABLE ctagmap("\
52+
"tag_id INTEGER NOT NULL,"\
53+
"colorramp_id INTEGER)"
5554

5655
_smartgroup = "CREATE TABLE smartgroup("\
5756
"id INTEGER PRIMARY KEY,"\
5857
"name TEXT,"\
5958
"xml TEXT)"
6059

61-
_ctagmap = "CREATE TABLE ctagmap("\
62-
"tag_id INTEGER NOT NULL,"\
63-
"colorramp_id INTEGER)"
64-
65-
create_tables = [ _symbol, _colorramp, _tag, _tagmap, _ctagmap, _symgroup, _smartgroup ]
60+
create_tables = [_symbol, _colorramp, _tag, _tagmap, _ctagmap, _smartgroup]
6661

6762
# Create the DB with required Schema
68-
conn = sqlite3.connect( dbfile )
63+
conn = sqlite3.connect(dbfile)
6964
c = conn.cursor()
7065
print "Creating tables in the Database\n"
7166
for table in create_tables:
7267
try:
73-
c.execute( table )
68+
c.execute(table)
7469
print table
7570
except sqlite3.OperationalError as e:
7671
pass
7772
conn.commit()
7873

7974
# parse the XML file & write symbol into DB
80-
dom = parse( xmlfile )
81-
symbols = dom.getElementsByTagName( "symbol" )
75+
dom = parse(xmlfile)
76+
symbols = dom.getElementsByTagName("symbol")
8277
for symbol in symbols:
83-
symbol_name = symbol.getAttribute( "name" )
78+
symbol_name = symbol.getAttribute("name")
79+
symbol_favorite = symbol.getAttribute("favorite")
80+
if not symbol_favorite:
81+
symbol_favorite = 0
82+
8483
if '@' in symbol_name:
8584
parts = symbol_name.split('@')
8685
parent_name = parts[1]
8786
layerno = int(parts[2])
88-
c.execute( "SELECT xml FROM symbol WHERE name=(?)", (parent_name,) )
89-
symdom = parseString( c.fetchone()[0] ).getElementsByTagName( 'symbol' )[0]
90-
symdom.getElementsByTagName( "layer" )[ layerno ].appendChild( symbol )
91-
c.execute( "UPDATE symbol SET xml=? WHERE name=?", ( symdom.toxml(), parent_name ))
87+
c.execute("SELECT xml FROM symbol WHERE name=(?)", (parent_name,))
88+
symdom = parseString(c.fetchone()[0]).getElementsByTagName('symbol')[0]
89+
symdom.getElementsByTagName("layer")[layerno].appendChild(symbol)
90+
c.execute("UPDATE symbol SET xml=? WHERE name=?", (symdom.toxml(), parent_name))
9291
else:
93-
c.execute( "INSERT INTO symbol VALUES (?,?,?,?)", ( None, symbol_name, symbol.toxml(), 0 ) )
92+
c.execute("INSERT INTO symbol VALUES (?,?,?,?)", (None, symbol_name, symbol.toxml(), symbol_favorite))
9493
conn.commit()
9594

9695

9796
# ColorRamps
98-
colorramps = dom.getElementsByTagName( "colorramp" )
97+
colorramps = dom.getElementsByTagName("colorramp")
9998
for ramp in colorramps:
100-
ramp_name = ramp.getAttribute( "name" )
101-
c.execute( "INSERT INTO colorramp VALUES (?,?,?,?)", ( None, ramp_name, ramp.toxml(), 0 ) )
99+
ramp_name = ramp.getAttribute("name")
100+
symbol_favorite = symbol.getAttribute("favorite")
101+
if not symbol_favorite:
102+
symbol_favorite = 0
103+
104+
c.execute("INSERT INTO colorramp VALUES (?,?,?,?)", (None, ramp_name, ramp.toxml(), symbol_favorite))
102105
conn.commit()
103106

104107
# Finally close the sqlite cursor

0 commit comments

Comments
 (0)
Please sign in to comment.