Skip to content
Permalink
Browse files

Merge pull request #3755 from nirvn/style_manager_upgrade

[FEATURE] Style management re-work and upgrade
  • Loading branch information
nyalldawson committed Nov 17, 2016
2 parents 964ecfd + 5e487cf commit e624518e0062c18ddffba51ec364ebd1d85db703
Showing with 1,186 additions and 929 deletions.
  1. +5 −0 doc/api_break.dox
  2. +98 −102 python/core/symbology-ng/qgsstyle.sip
  3. +1 −0 python/gui/gui.sip
  4. +6 −6 python/gui/symbology-ng/qgsstyleexportimportdialog.sip
  5. +4 −4 python/gui/symbology-ng/qgsstylegroupselectiondialog.sip
  6. +10 −11 python/gui/symbology-ng/qgsstylemanagerdialog.sip
  7. +22 −0 python/gui/symbology-ng/qgsstylesavedialog.sip
  8. +2 −1 python/gui/symbology-ng/qgssymbolslistwidget.sip
  9. BIN resources/symbology-ng-style.db
  10. +1 −1 resources/symbology-ng-style.xml
  11. +27 −24 scripts/symbol_xml2db.py
  12. +150 −192 src/core/symbology-ng/qgsstyle.cpp
  13. +120 −123 src/core/symbology-ng/qgsstyle.h
  14. +2 −0 src/gui/CMakeLists.txt
  15. +1 −3 src/gui/symbology-ng/qgssmartgroupeditordialog.cpp
  16. +31 −51 src/gui/symbology-ng/qgsstyleexportimportdialog.cpp
  17. +7 −7 src/gui/symbology-ng/qgsstyleexportimportdialog.h
  18. +24 −31 src/gui/symbology-ng/qgsstylegroupselectiondialog.cpp
  19. +5 −5 src/gui/symbology-ng/qgsstylegroupselectiondialog.h
  20. +249 −248 src/gui/symbology-ng/qgsstylemanagerdialog.cpp
  21. +10 −11 src/gui/symbology-ng/qgsstylemanagerdialog.h
  22. +56 −0 src/gui/symbology-ng/qgsstylesavedialog.cpp
  23. +57 −0 src/gui/symbology-ng/qgsstylesavedialog.h
  24. +83 −63 src/gui/symbology-ng/qgssymbolslistwidget.cpp
  25. +4 −3 src/gui/symbology-ng/qgssymbolslistwidget.h
  26. +23 −7 src/ui/qgsstyleexportimportdialogbase.ui
  27. +29 −27 src/ui/qgsstylemanagerdialogbase.ui
  28. +126 −0 src/ui/qgsstylesavedialog.ui
  29. +2 −8 src/ui/symbollayer/widget_symbolslist.ui
  30. +31 −1 tests/src/core/testqgsstyle.cpp
@@ -1371,6 +1371,11 @@ QgsSvgCache {#qgis_api_break_3_0_QgsSvgCache}

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

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

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

Large diffs are not rendered by default.

@@ -247,6 +247,7 @@
%Include symbology-ng/qgsstyleexportimportdialog.sip
%Include symbology-ng/qgsstylegroupselectiondialog.sip
%Include symbology-ng/qgsstylemanagerdialog.sip
%Include symbology-ng/qgsstylesavedialog.sip
%Include symbology-ng/qgssvgselectorwidget.sip
%Include symbology-ng/qgssymbollayerwidget.sip
%Include symbology-ng/qgssymbollevelsdialog.sip
@@ -41,15 +41,15 @@ class QgsStyleExportImportDialog : QDialog
*/
void clearSelection();
/**
* Select the symbols belonging to the given group
* @param groupName the name of the group to be selected
* Select the symbols belonging to the given tag
* @param tagName the name of the tag to be selected
*/
void selectGroup( const QString& groupName );
void selectTag( const QString& tagName );
/**
* Deselect the symbols belonging to the given group
* @param groupName the name of the group to be deselected
* Deselect the symbols belonging to the given tag
* @param tagName the name of the tag to be deselected
*/
void deselectGroup( const QString& groupName );
void deselectTag( const QString& tagName );
/**
* @brief selectSmartgroup selects all symbols from a smart group
* @param groupName
@@ -28,10 +28,10 @@ class QgsStyleGroupSelectionDialog : public QDialog, private Ui::SymbolsGroupSel
void setBold( QStandardItem *item );

signals:
//! group with groupName has been selected
void groupSelected( const QString& groupName );
//! group with groupName has been deselected
void groupDeselected( const QString& groupName );
//! tag with tagName has been selected
void tagSelected( const QString& tagName );
//! tag with tagName has been deselected
void tagDeselected( const QString& tagName );
//! smartgroup with groupName has been selected
void smartgroupSelected( const QString& groupName );
//! smart group with groupName has been deselected
@@ -37,8 +37,8 @@ class QgsStyleManagerDialog : QDialog
void addGroup();
void removeGroup();

//! carryout symbol grouping using check boxes
void groupSymbolsAction();
//! carry out symbol tagging using check boxes
void tagSymbolsAction();

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

//! Listen to tag changes
void tagsChanged();

//! Perform symbol specific tasks when selected
void symbolSelected( const QModelIndex& );

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

protected slots:
bool addColorRamp( QAction* action );
void groupSelectedSymbols();
//! Add selected symbols to favorites
void addFavoriteSelectedSymbols();
//! Remove selected symbols from favorites
void removeFavoriteSelectedSymbols();
//! Tag selected symbols using menu item selection
void tagSelectedSymbols();
//! Remove all tags from selected symbols
void detagSelectedSymbols();

protected:

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

//! populate the groups
void populateGroups();
//! build the groups tree
void buildGroupTree( QStandardItem* &parent );
//! to set symbols checked when in editing mode
void setSymbolsChecked( const QStringList& );

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

//! Event filter to capture tagsLineEdit out of focus
bool eventFilter( QObject*, QEvent* );

//! sets the text of the item with bold font
void setBold( QStandardItem* );
};
@@ -0,0 +1,22 @@
class QgsStyleSaveDialog : QDialog
{
%TypeHeaderCode
#include <qgsstylesavedialog.h>
%End

public:
/** Constructor for QgsSymbolSaveDialog
* @param parent parent widget
* @param type the QgsStyle entity type being saved
*/
QgsStyleSaveDialog( QWidget* parent /TransferThis/ = NULL, QgsStyle::StyleEntity type = QgsStyle::SymbolEntity );

//! returns the text value of the name element
QString name() const;

//! returns the text value of the tags element
QString tags() const;

//! returns whether the favorite element is checked
bool isFavorite() const;
};
@@ -37,8 +37,9 @@ class QgsSymbolsListWidget : QWidget
void on_mSymbolUnitWidget_changed();
void on_mTransparencySlider_valueChanged( int value );

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

void openStyleManager();
void clipFeaturesToggled( bool checked );
Binary file not shown.
@@ -838,7 +838,7 @@
<prop k="width_unit" v="MM"/>
</layer>
</symbol>
<symbol alpha="1" type="marker" name="airport">
<symbol alpha="1" type="marker" name="airport" favorite="1">
<layer pass="0" class="SvgMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="fill" v="#000000"/>
@@ -32,13 +32,13 @@
"id INTEGER PRIMARY KEY,"\
"name TEXT UNIQUE,"\
"xml TEXT,"\
"groupid INTEGER)"
"favorite INTEGER)"

_colorramp = "CREATE TABLE colorramp("\
"id INTEGER PRIMARY KEY,"\
"name TEXT UNIQUE,"\
"xml TEXT,"\
"groupid INTEGER)"
"favorite INTEGER)"

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

_symgroup = "CREATE TABLE symgroup("\
"id INTEGER PRIMARY KEY,"\
"name TEXT,"\
"parent INTEGER)"
_ctagmap = "CREATE TABLE ctagmap("\
"tag_id INTEGER NOT NULL,"\
"colorramp_id INTEGER)"

_smartgroup = "CREATE TABLE smartgroup("\
"id INTEGER PRIMARY KEY,"\
"name TEXT,"\
"xml TEXT)"

_ctagmap = "CREATE TABLE ctagmap("\
"tag_id INTEGER NOT NULL,"\
"colorramp_id INTEGER)"

create_tables = [ _symbol, _colorramp, _tag, _tagmap, _ctagmap, _symgroup, _smartgroup ]
create_tables = [_symbol, _colorramp, _tag, _tagmap, _ctagmap, _smartgroup]

# Create the DB with required Schema
conn = sqlite3.connect( dbfile )
conn = sqlite3.connect(dbfile)
c = conn.cursor()
print "Creating tables in the Database\n"
for table in create_tables:
try:
c.execute( table )
c.execute(table)
print table
except sqlite3.OperationalError as e:
pass
conn.commit()

# parse the XML file & write symbol into DB
dom = parse( xmlfile )
symbols = dom.getElementsByTagName( "symbol" )
dom = parse(xmlfile)
symbols = dom.getElementsByTagName("symbol")
for symbol in symbols:
symbol_name = symbol.getAttribute( "name" )
symbol_name = symbol.getAttribute("name")
symbol_favorite = symbol.getAttribute("favorite")
if not symbol_favorite:
symbol_favorite = 0

if '@' in symbol_name:
parts = symbol_name.split('@')
parent_name = parts[1]
layerno = int(parts[2])
c.execute( "SELECT xml FROM symbol WHERE name=(?)", (parent_name,) )
symdom = parseString( c.fetchone()[0] ).getElementsByTagName( 'symbol' )[0]
symdom.getElementsByTagName( "layer" )[ layerno ].appendChild( symbol )
c.execute( "UPDATE symbol SET xml=? WHERE name=?", ( symdom.toxml(), parent_name ))
c.execute("SELECT xml FROM symbol WHERE name=(?)", (parent_name,))
symdom = parseString(c.fetchone()[0]).getElementsByTagName('symbol')[0]
symdom.getElementsByTagName("layer")[layerno].appendChild(symbol)
c.execute("UPDATE symbol SET xml=? WHERE name=?", (symdom.toxml(), parent_name))
else:
c.execute( "INSERT INTO symbol VALUES (?,?,?,?)", ( None, symbol_name, symbol.toxml(), 0 ) )
c.execute("INSERT INTO symbol VALUES (?,?,?,?)", (None, symbol_name, symbol.toxml(), symbol_favorite))
conn.commit()


# ColorRamps
colorramps = dom.getElementsByTagName( "colorramp" )
colorramps = dom.getElementsByTagName("colorramp")
for ramp in colorramps:
ramp_name = ramp.getAttribute( "name" )
c.execute( "INSERT INTO colorramp VALUES (?,?,?,?)", ( None, ramp_name, ramp.toxml(), 0 ) )
ramp_name = ramp.getAttribute("name")
symbol_favorite = symbol.getAttribute("favorite")
if not symbol_favorite:
symbol_favorite = 0

c.execute("INSERT INTO colorramp VALUES (?,?,?,?)", (None, ramp_name, ramp.toxml(), symbol_favorite))
conn.commit()

# Finally close the sqlite cursor

0 comments on commit e624518

Please sign in to comment.
You can’t perform that action at this time.