26 #include <QDomDocument>
27 #include <QDomElement>
29 #include <QDomNodeList>
31 #include <QTextStream>
36 #define STYLE_CURRENT_VERSION "1"
85 if ( !symbol || name.
isEmpty() )
116 QgsDebugMsg(
"Couldn't convert symbol to valid XML!" );
123 symEl.
save( stream, 4 );
124 char *query = sqlite3_mprintf(
"INSERT INTO symbol VALUES (NULL, '%q', '%q', %d);",
129 QgsDebugMsg(
"Couldn't insert symbol into the database!" );
151 QgsDebugMsg(
"Sorry! Cannot open database to tag." );
158 QgsDebugMsg(
"No such symbol for deleting in database: " + name +
". Cheers." );
169 return symbol ? symbol->
clone() : 0;
190 if ( !colorRamp || name.
isEmpty() )
222 QgsDebugMsg(
"Couldn't convert color ramp to valid XML!" );
229 rampEl.
save( stream, 4 );
230 char *query = sqlite3_mprintf(
"INSERT INTO colorramp VALUES (NULL, '%q', '%q', %d);",
235 QgsDebugMsg(
"Couldn't insert colorramp into the database!" );
248 char *query = sqlite3_mprintf(
"DELETE FROM colorramp WHERE name='%q'", name.
toUtf8().
constData() );
251 QgsDebugMsg(
"Couldn't remove color ramp from the database." );
263 return ramp ? ramp->
clone() : 0;
299 if ( !
openDB( filename ) )
301 mErrorString =
"Unable to open database file specified";
307 char *query = sqlite3_mprintf(
"UPDATE symbol SET groupid=0 WHERE groupid IS NULL;"
308 "UPDATE colorramp SET groupid=0 WHERE groupid IS NULL;"
309 "UPDATE symgroup SET parent=0 WHERE parent IS NULL;" );
313 query = sqlite3_mprintf(
"SELECT * FROM symbol" );
315 sqlite3_stmt *ppStmt;
316 int nError = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
317 while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
324 QgsDebugMsg(
"Cannot open symbol " + symbol_name );
330 if ( symbol != NULL )
334 sqlite3_finalize( ppStmt );
336 query = sqlite3_mprintf(
"SELECT * FROM colorramp" );
337 nError = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
338 while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
391 if ( !f.
open( QFile::WriteOnly ) )
393 mErrorString =
"Couldn't open file for writing: " + filename;
410 QgsDebugMsg(
"Symbol of new name already exists" );
422 QgsDebugMsg(
"Sorry! Cannot open database to tag." );
429 QgsDebugMsg(
"No such symbol for tagging in database: " + oldName );
442 QgsDebugMsg(
"Color ramp of new name already exists." );
453 sqlite3_stmt *ppStmt;
454 char *query = sqlite3_mprintf(
"SELECT id FROM colorramp WHERE name='%q'", oldName.
toUtf8().
constData() );
455 int nErr = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
456 if ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
458 rampid = sqlite3_column_int( ppStmt, 0 );
460 sqlite3_finalize( ppStmt );
469 sqlite3_stmt *ppStmt;
470 const char *query =
"SELECT * FROM symgroup";
471 int nError = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
472 while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
476 sqlite3_finalize( ppStmt );
485 QgsDebugMsg(
"Cannot open database for listing groups" );
491 sqlite3_stmt *ppStmt;
494 if ( parent ==
"" || parent ==
QString() )
496 query = sqlite3_mprintf(
"SELECT * FROM symgroup WHERE parent=0" );
500 char *subquery = sqlite3_mprintf(
"SELECT * FROM symgroup WHERE name='%q'", parent.
toUtf8().
constData() );
501 nError = sqlite3_prepare_v2(
mCurrentDB, subquery, -1, &ppStmt, NULL );
502 if ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
504 query = sqlite3_mprintf(
"SELECT * FROM symgroup WHERE parent=%d", sqlite3_column_int( ppStmt,
SymgroupId ) );
506 sqlite3_finalize( ppStmt );
515 nError = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
516 while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
522 sqlite3_finalize( ppStmt );
531 QgsDebugMsg(
QString(
"Cannot Open database for getting group symbols of groupid: %1" ).arg( groupid ) );
538 query = sqlite3_mprintf(
"SELECT name FROM symbol WHERE groupid=%d", groupid );
542 query = sqlite3_mprintf(
"SELECT name FROM colorramp WHERE groupid=%d", groupid );
550 sqlite3_stmt *ppStmt;
551 int nErr = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
554 while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
556 symbols <<
QString::fromUtf8((
const char * ) sqlite3_column_text( ppStmt, 0 ) );
559 sqlite3_finalize( ppStmt );
568 QgsDebugMsg(
QString(
"Cannot open database to get symbols of tagid %1" ).arg( tagid ) );
575 subquery = sqlite3_mprintf(
"SELECT symbol_id FROM tagmap WHERE tag_id=%d", tagid );
579 subquery = sqlite3_mprintf(
"SELECT symbol_id FROM ctagmap WHERE tag_id=%d", tagid );
587 sqlite3_stmt *ppStmt;
588 int nErr = sqlite3_prepare_v2(
mCurrentDB, subquery, -1, &ppStmt, NULL );
592 while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
594 int symbolId = sqlite3_column_int( ppStmt, 0 );
597 ? sqlite3_mprintf(
"SELECT name FROM symbol WHERE id=%d", symbolId )
598 : sqlite3_mprintf(
"SELECT name FROM colorramp WHERE id=%d", symbolId );
600 sqlite3_stmt *ppStmt2;
601 int sErr = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt2, NULL );
602 while ( sErr == SQLITE_OK && sqlite3_step( ppStmt2 ) == SQLITE_ROW )
604 symbols <<
QString::fromUtf8((
const char * ) sqlite3_column_text( ppStmt2, 0 ) );
606 sqlite3_finalize( ppStmt2 );
608 sqlite3_finalize( ppStmt );
618 char *query = sqlite3_mprintf(
"INSERT INTO symgroup VALUES (NULL, '%q', %d)", groupName.
toUtf8().
constData(), parentid );
620 sqlite3_stmt *ppStmt;
621 int nErr = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
622 if ( nErr == SQLITE_OK )
623 ( void )sqlite3_step( ppStmt );
625 sqlite3_finalize( ppStmt );
627 return (
int )sqlite3_last_insert_rowid(
mCurrentDB );
634 sqlite3_stmt *ppStmt;
636 char *query = sqlite3_mprintf(
"INSERT INTO tag VALUES (NULL, '%q')", tagname.
toUtf8().
constData() );
637 int nErr = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
638 if ( nErr == SQLITE_OK )
639 ( void )sqlite3_step( ppStmt );
640 sqlite3_finalize( ppStmt );
642 return (
int )sqlite3_last_insert_rowid(
mCurrentDB );
651 query = sqlite3_mprintf(
"UPDATE symbol SET name='%q' WHERE id=%d", newName.
toUtf8().
constData(), id );
654 query = sqlite3_mprintf(
"UPDATE symgroup SET name='%q' WHERE id=%d", newName.
toUtf8().
constData(), id );
657 query = sqlite3_mprintf(
"UPDATE tag SET name='%q' WHERE id=%d", newName.
toUtf8().
constData(), id );
660 query = sqlite3_mprintf(
"UPDATE colorramp SET name='%q' WHERE id=%d", newName.
toUtf8().
constData(), id );
663 query = sqlite3_mprintf(
"UPDATE smartgroup SET name='%q' WHERE id=%d", newName.
toUtf8().
constData(), id );
675 char *query = sqlite3_mprintf(
"SELECT parent FROM symgroup WHERE id=%d",
id );
677 sqlite3_stmt *ppStmt;
678 int err = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
681 if ( err == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
682 parentid = sqlite3_column_int( ppStmt, 0 );
684 sqlite3_finalize( ppStmt );
686 return sqlite3_mprintf(
"UPDATE symbol SET groupid=%d WHERE groupid=%d;"
687 "UPDATE symgroup SET parent=%d WHERE parent=%d;"
688 "DELETE FROM symgroup WHERE id=%d", parentid,
id, parentid,
id,
id );
697 query = sqlite3_mprintf(
"DELETE FROM symbol WHERE id=%d; DELETE FROM tagmap WHERE symbol_id=%d",
id,
id );
703 query = sqlite3_mprintf(
"DELETE FROM tag WHERE id=%d; DELETE FROM tagmap WHERE tag_id=%d",
id,
id );
706 query = sqlite3_mprintf(
"DELETE FROM colorramp WHERE id=%d",
id );
709 query = sqlite3_mprintf(
"DELETE FROM smartgroup WHERE id=%d",
id );
728 int nErr = sqlite3_exec(
mCurrentDB, query, NULL, NULL, &zErr );
732 sqlite3_free( query );
735 if ( nErr != SQLITE_OK )
740 return zErr == SQLITE_OK;
750 query = sqlite3_mprintf(
"UPDATE symbol SET groupid=%d WHERE name='%q'", groupid, name.
toUtf8().
constData() );
753 query = sqlite3_mprintf(
"UPDATE colorramp SET groupid=%d WHERE name='%q'", groupid, name.
toUtf8().
constData() );
757 QgsDebugMsg(
"Wrong entity value. cannot apply group" );
768 QgsDebugMsg(
"Sorry! Cannot open database to search" );
773 char *query = sqlite3_mprintf(
"SELECT name FROM %q WHERE name LIKE '%%%q%%'",
776 sqlite3_stmt *ppStmt;
777 int nErr = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
780 while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
782 symbols <<
QString::fromUtf8((
const char * ) sqlite3_column_text( ppStmt, 0 ) );
785 sqlite3_finalize( ppStmt );
794 QgsDebugMsg(
"Sorry! Cannot open database to tag." );
801 QgsDebugMsg(
"No such symbol for tagging in database: " + symbol );
806 Q_FOREACH (
const QString &tag, tags )
809 char *query = sqlite3_mprintf(
"SELECT id FROM tag WHERE name='%q'", tag.
toUtf8().
constData() );
811 sqlite3_stmt *ppStmt;
812 int nErr = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
815 if ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
817 tagid = sqlite3_column_int( ppStmt, 0 );
824 sqlite3_finalize( ppStmt );
828 ? sqlite3_mprintf(
"INSERT INTO tagmap VALUES (%d,%d)", tagid, symbolid )
829 : sqlite3_mprintf(
"INSERT INTO ctagmap VALUES (%d,%d)", tagid, symbolid );
832 nErr = sqlite3_exec(
mCurrentDB, query, NULL, NULL, &zErr );
846 QgsDebugMsg(
"Sorry! Cannot open database for detgging." );
851 ? sqlite3_mprintf(
"SELECT id FROM symbol WHERE name='%q'", symbol.
toUtf8().
constData() )
852 : sqlite3_mprintf(
"SELECT id FROM colorramp WHERE name='%q'", symbol.
toUtf8().
constData() );
853 sqlite3_stmt *ppStmt;
854 int nErr = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
857 if ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
859 symbolid = sqlite3_column_int( ppStmt, 0 );
862 sqlite3_finalize( ppStmt );
864 Q_FOREACH (
const QString &tag, tags )
866 query = sqlite3_mprintf(
"SELECT id FROM tag WHERE name='%q'", tag.
toUtf8().
constData() );
868 sqlite3_stmt *ppStmt2;
869 nErr = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt2, NULL );
872 if ( nErr == SQLITE_OK && sqlite3_step( ppStmt2 ) == SQLITE_ROW )
874 tagid = sqlite3_column_int( ppStmt2, 0 );
877 sqlite3_finalize( ppStmt2 );
883 ? sqlite3_mprintf(
"DELETE FROM tagmap WHERE tag_id=%d AND symbol_id=%d", tagid, symbolid )
884 : sqlite3_mprintf(
"DELETE FROM ctagmap WHERE tag_id=%d AND colorramp_id=%d", tagid, symbolid );
899 QgsDebugMsg(
"Sorry! Cannot open database for getting the tags." );
909 ? sqlite3_mprintf(
"SELECT tag_id FROM tagmap WHERE symbol_id=%d", symbolid )
910 : sqlite3_mprintf(
"SELECT tag_id FROM ctagmap WHERE colorramp_id=%d", symbolid );
912 sqlite3_stmt *ppStmt;
913 int nErr = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
916 while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
918 char *subquery = sqlite3_mprintf(
"SELECT name FROM tag WHERE id=%d", sqlite3_column_int( ppStmt, 0 ) );
920 sqlite3_stmt *ppStmt2;
921 int pErr = sqlite3_prepare_v2(
mCurrentDB, subquery, -1, &ppStmt2, NULL );
922 if ( pErr == SQLITE_OK && sqlite3_step( ppStmt2 ) == SQLITE_ROW )
924 tagList <<
QString::fromUtf8((
const char * ) sqlite3_column_text( ppStmt2, 0 ) );
926 sqlite3_finalize( ppStmt2 );
929 sqlite3_finalize( ppStmt );
938 sqlite3_stmt *ppStmt;
939 int nErr = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
942 if ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
944 id = sqlite3_column_int( ppStmt, 0 );
947 sqlite3_finalize( ppStmt );
954 return getId(
"symbol", name );
959 return getId(
"colorramp", name );
964 return getId(
"symgroup", name );
969 return getId(
"tag", name );
974 return getId(
"smartgroup", name );
985 constraints <<
"tag" <<
"group" <<
"name" <<
"!tag" <<
"!group" <<
"!name";
987 Q_FOREACH (
const QString &constraint, constraints )
990 Q_FOREACH (
const QString ¶m, parameters )
1002 smartEl.
save( stream, 4 );
1003 char *query = sqlite3_mprintf(
"INSERT INTO smartgroup VALUES (NULL, '%q', '%q')",
1008 return (
int )sqlite3_last_insert_rowid(
mCurrentDB );
1012 QgsDebugMsg(
"Couldn't insert symbol into the database!" );
1021 QgsDebugMsg(
"Cannot open database for listing groups" );
1025 char *query = sqlite3_mprintf(
"SELECT * FROM smartgroup" );
1028 sqlite3_stmt *ppStmt;
1029 int nError = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
1032 while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
1038 sqlite3_finalize( ppStmt );
1047 QgsDebugMsg(
"Cannot open database for listing groups" );
1051 char *query = sqlite3_mprintf(
"SELECT name FROM smartgroup" );
1054 sqlite3_stmt *ppStmt;
1055 int nError = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
1058 while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
1060 groups <<
QString::fromUtf8((
const char * ) sqlite3_column_text( ppStmt, 0 ) );
1063 sqlite3_finalize( ppStmt );
1072 char *query = sqlite3_mprintf(
"SELECT xml FROM smartgroup WHERE id=%d",
id );
1074 sqlite3_stmt *ppStmt;
1075 int nErr = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
1076 if ( !( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW ) )
1078 sqlite3_finalize( ppStmt );
1093 bool firstSet =
true;
1094 for (
int i = 0; i < conditionNodes.
count(); i++ )
1102 if ( constraint ==
"tag" )
1106 else if ( constraint ==
"group" )
1112 else if ( constraint ==
"name" )
1123 else if ( constraint ==
"!tag" )
1132 else if ( constraint ==
"!group" )
1141 else if ( constraint ==
"!name" )
1144 Q_FOREACH (
const QString &str, all )
1146 if ( !str.
contains( param, Qt::CaseInsensitive ) )
1154 symbols = resultNames;
1161 symbols << resultNames;
1163 else if ( op ==
"AND" )
1167 Q_FOREACH (
const QString &result, resultNames )
1177 sqlite3_finalize( ppStmt );
1186 QgsDebugMsg(
"Cannot open database for listing groups" );
1192 char *query = sqlite3_mprintf(
"SELECT xml FROM smartgroup WHERE id=%d",
id );
1194 sqlite3_stmt *ppStmt;
1195 int nError = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
1196 if ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
1209 for (
int i = 0; i < conditionNodes.
count(); i++ )
1215 condition.
insert( constraint, param );
1219 sqlite3_finalize( ppStmt );
1228 QgsDebugMsg(
"Cannot open database for listing groups" );
1234 char *query = sqlite3_mprintf(
"SELECT xml FROM smartgroup WHERE id=%d",
id );
1236 sqlite3_stmt *ppStmt;
1237 int nError = sqlite3_prepare_v2(
mCurrentDB, query, -1, &ppStmt, NULL );
1238 if ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
1250 sqlite3_finalize( ppStmt );
1259 QgsDebugMsg(
"Invalid filename for style export." );
1283 QFile f( filename );
1284 if ( !f.
open( QFile::WriteOnly ) )
1286 mErrorString =
"Couldn't open file for writing: " + filename;
1303 QFile f( filename );
1304 if ( !f.
open( QFile::ReadOnly ) )
1307 QgsDebugMsg(
"Error opening the style XML file." );
1321 if ( docEl.
tagName() !=
"qgis_style" )
1330 mErrorString =
"Unknown style file version: " + version;
1344 if ( e.
tagName() ==
"symbol" )
1376 if ( e.
tagName() ==
"colorramp" )
1410 QgsDebugMsg(
"Update request received for unavailable symbol" );
1417 QgsDebugMsg(
"Couldn't convert symbol to valid XML!" );
1420 symEl.
save( stream, 4 );
1421 query = sqlite3_mprintf(
"UPDATE symbol SET xml='%q' WHERE name='%q';",
1428 QgsDebugMsg(
"Update requested for unavailable color ramp." );
1435 QgsDebugMsg(
"Couldn't convert color ramp to valid XML!" );
1438 symEl.
save( stream, 4 );
1439 query = sqlite3_mprintf(
"UPDATE colorramp SET xml='%q' WHERE name='%q';",
1444 QgsDebugMsg(
"Updating the unsupported StyleEntity" );
1451 QgsDebugMsg(
"Couldn't insert symbol into the database!" );
QStringList tagsOfSymbol(StyleEntity type, const QString &symbol)
return the tags associated with the symbol
void setCodec(QTextCodec *codec)
QString smartgroupOperator(int id)
returns the operator for the smartgroup
static QDomElement saveSymbols(QgsSymbolV2Map &symbols, const QString &tagName, QDomDocument &doc)
int getId(const QString &table, const QString &name)
gets the id from the table for the given name from the database, 0 if not found
static QgsSymbolV2Map loadSymbols(QDomElement &element)
const QgsVectorColorRampV2 * colorRampRef(const QString &name) const
return a const pointer to a symbol (doesn't create new instance)
bool saveColorRamp(const QString &name, QgsVectorColorRampV2 *ramp, int groupid, const QStringList &tags)
add the colorramp to the DB
void remove(StyleEntity type, int id)
remove the specified entity from the db
QgsVectorColorRampV2 * colorRamp(const QString &name)
return a NEW copy of color ramp
bool contains(const Key &key) const
static QgsVectorColorRampV2 * loadColorRamp(QDomElement &element)
bool importXML(const QString &filename)
Imports the symbols and colorramps into the default style database from the given XML file...
bool tagSymbol(StyleEntity type, const QString &symbol, const QStringList &tags)
tags the symbol with the tags in the list
bool group(StyleEntity type, const QString &name, int groupid)
applies the specified group to the symbol or colorramp specified by StyleEntity
QList< T > values() const
QDomNode appendChild(const QDomNode &newChild)
bool addSymbol(const QString &name, QgsSymbolV2 *symbol, bool update=false)
add symbol to style. takes symbol's ownership
QString attribute(const QString &name, const QString &defValue) const
int groupId(const QString &group)
return the DB id for the given group name
static QDomElement saveColorRamp(const QString &name, QgsVectorColorRampV2 *ramp, QDomDocument &doc)
virtual QgsSymbolV2 * clone() const =0
QMultiMap< QString, QString > QgsSmartConditionMap
QStringList symbolsOfGroup(StyleEntity type, int groupid)
returns the symbolnames of a given groupid
bool contains(const QString &str, Qt::CaseSensitivity cs) const
static QDomElement saveSymbol(const QString &symbolName, QgsSymbolV2 *symbol, QDomDocument &doc)
QDomElement nextSiblingElement(const QString &tagName) const
bool exportXML(const QString &filename)
Exports the style as a XML file.
bool addColorRamp(const QString &name, QgsVectorColorRampV2 *colorRamp, bool update=false)
add color ramp to style. takes ramp's ownership
QDomElement documentElement() const
bool detagSymbol(StyleEntity type, const QString &symbol, const QStringList &tags)
detags the symbol with the given list
bool updateSymbol(StyleEntity type, const QString &name)
updates the properties of an existing symbol/colorramp
QDomNodeList childNodes() const
QStringList colorRampNames()
return a list of names of color ramps
char * getGroupRemoveQuery(int id)
prepares the complex query for removing a group, so that the children are not abandoned ...
bool copy(const QString &newName)
static QgsSymbolV2 * loadSymbol(const QDomElement &element)
Attempts to load a symbol from a DOM element.
bool save(QString filename=QString())
save style into a file (will use current filename if empty string is passed)
QDomElement toElement() const
void symbolSaved(QString name, QgsSymbolV2 *symbol)
QList< Key > keys() const
const char * name() const
QgsSymbolGroupMap childGroupNames(const QString &parent="")
return a map of groupid and names for the given parent group
bool renameColorRamp(const QString &oldName, const QString &newName)
change ramp's name
QString fromUtf8(const char *str, int size)
bool saveSymbol(const QString &name, QgsSymbolV2 *symbol, int groupid, const QStringList &tags)
add the symbol to the DB with the tags
int colorRampCount()
return count of color ramps
static QgsStyleV2 * mDefaultStyle
void setAttribute(const QString &name, const QString &value)
virtual QgsVectorColorRampV2 * clone() const =0
const QgsSymbolV2 * symbolRef(const QString &name) const
return a const pointer to a symbol (doesn't create new instance)
static QgsStyleV2 * defaultStyle()
return default application-wide style
int removeAll(const T &value)
const char * constData() const
void rename(StyleEntity type, int id, const QString &newName)
rename the given entity with the specified id
QMap< Key, T >::iterator insert(const Key &key, const T &value)
QStringList symbolsOfSmartgroup(StyleEntity type, int id)
returns the symbols for the smartgroup
bool runEmptyQuery(char *query, bool freeQuery=true)
convenience function that would run queries which don't generate return values
int addTag(const QString &tagName)
adds a new tag and returns the tag's id
QStringList symbolNames()
return a list of names of symbols
QMap< int, QString > QgsSymbolGroupMap
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
QgsSymbolGroupMap smartgroupsListMap()
returns the smart groups map with id as key and name as value
int tagId(const QString &tag)
return the DB id for the given tag name
QgsSymbolV2 * symbol(const QString &name)
return a NEW copy of symbol
bool contains(QChar ch, Qt::CaseSensitivity cs) const
static QString defaultStyleV2Path()
Returns the path to default style (works as a starting point).
static QString userStyleV2Path()
Returns the path to user's style.
QgsVectorColorRampV2Map mColorRamps
QStringList smartgroupNames()
returns the smart groups list
QStringList symbolsWithTag(StyleEntity type, int tagid)
returns the symbol names with which have the given tag
void clear()
remove all contents of the style
bool load(const QString &filename)
load a file into the style
void save(QTextStream &str, int indent) const
bool renameSymbol(const QString &oldName, const QString &newName)
change symbol's name
QDomElement firstChildElement(const QString &tagName) const
int symbolCount()
return count of symbols in style
iterator insert(const Key &key, const T &value)
bool removeColorRamp(const QString &name)
remove color ramp from style (and delete it)
QStringList filter(const QString &str, Qt::CaseSensitivity cs) const
QDomElement createElement(const QString &tagName)
StyleEntity
Enum for Entities involved in a style.
int smartgroupId(const QString &smartgroup)
return the DB id for the given smartgroup name
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
bool openDB(const QString &filename)
convenience function to open the DB and return a sqlite3 object
int count(const Key &key) const
QStringList findSymbols(StyleEntity type, const QString &qword)
return the names of the symbols which have a matching 'substring' in its defintion ...
QStringList groupNames()
return the all the groups in the style
#define STYLE_CURRENT_VERSION
int addGroup(const QString &groupName, int parent=0)
adds a new group and returns the group's id
QgsSmartConditionMap smartgroup(int id)
returns the QgsSmartConditionMap for the given id
bool removeSymbol(const QString &name)
remove symbol from style (and delete it)
QDomNode at(int index) const
bool setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
int addSmartgroup(const QString &name, const QString &op, const QgsSmartConditionMap &conditions)
adds new smartgroup to the database and returns the id
int symbolId(const QString &name)
return the id in the style database for the given symbol name returns 0 if not found ...
const T value(const Key &key) const
QByteArray toUtf8() const
int colorrampId(const QString &name)
return the id in the style database for the given colorramp name returns 0 if not found ...