Skip to content
Permalink
Browse files

Use faster QColor constructor with r/g/b parameters

The QString based constructor is slow, as the string must
be parsed to interpret the color.

Thanks to Clazy
  • Loading branch information
nyalldawson committed Aug 29, 2017
1 parent 3abd0fa commit 52474785aadca37afaf774f131b192df80e33a5d
@@ -133,16 +133,16 @@ QgsNamedColorList QgsCustomColorScheme::fetchColors( const QString &context, con
if ( !settings.contains( QStringLiteral( "/colors/palettecolors" ) ) )
{
//no custom palette, return default colors
colorList.append( qMakePair( QColor( "#000000" ), QString() ) );
colorList.append( qMakePair( QColor( "#ffffff" ), QString() ) );
colorList.append( qMakePair( QColor( "#a6cee3" ), QString() ) );
colorList.append( qMakePair( QColor( "#1f78b4" ), QString() ) );
colorList.append( qMakePair( QColor( "#b2df8a" ), QString() ) );
colorList.append( qMakePair( QColor( "#33a02c" ), QString() ) );
colorList.append( qMakePair( QColor( "#fb9a99" ), QString() ) );
colorList.append( qMakePair( QColor( "#e31a1c" ), QString() ) );
colorList.append( qMakePair( QColor( "#fdbf6f" ), QString() ) );
colorList.append( qMakePair( QColor( "#ff7f00" ), QString() ) );
colorList.append( qMakePair( QColor( 0, 0, 0 ), QString() ) );
colorList.append( qMakePair( QColor( 255, 255, 255 ), QString() ) );
colorList.append( qMakePair( QColor( 166, 206, 227 ), QString() ) );
colorList.append( qMakePair( QColor( 31, 120, 180 ), QString() ) );
colorList.append( qMakePair( QColor( 178, 223, 138 ), QString() ) );
colorList.append( qMakePair( QColor( 51, 160, 44 ), QString() ) );
colorList.append( qMakePair( QColor( 251, 154, 153 ), QString() ) );
colorList.append( qMakePair( QColor( 227, 26, 28 ), QString() ) );
colorList.append( qMakePair( QColor( 253, 191, 111 ), QString() ) );
colorList.append( qMakePair( QColor( 255, 127, 0 ), QString() ) );

return colorList;
}
@@ -93,13 +93,13 @@ Qgs25DRenderer::Qgs25DRenderer()

// These methods must only be used after the above initialization!

setRoofColor( QColor( "#b1a97c" ) );
setWallColor( QColor( "#777777" ) );
setRoofColor( QColor( 177, 169, 124 ) );
setWallColor( QColor( 119, 119, 119 ) );

wallLayer()->setDataDefinedProperty( QgsSymbolLayer::PropertyFillColor, QgsProperty::fromExpression( QString( WALL_SHADING_EXPRESSION ) ) );

setShadowSpread( 4 );
setShadowColor( QColor( "#111111" ) );
setShadowColor( QColor( 17, 17, 17 ) );

QgsFeatureRequest::OrderBy orderBy;
orderBy << QgsFeatureRequest::OrderByClause(
@@ -1734,7 +1734,7 @@ bool QgsSymbolLayerUtils::fillFromSld( QDomElement &element, Qt::BrushStyle &bru
QgsDebugMsg( "Entered." );

brushStyle = Qt::SolidPattern;
color = QColor( "#808080" );
color = QColor( 128, 128, 128 );

if ( element.isNull() )
{
@@ -1875,7 +1875,7 @@ bool QgsSymbolLayerUtils::lineFromSld( QDomElement &element,
QgsDebugMsg( "Entered." );

penStyle = Qt::SolidLine;
color = QColor( "#000000" );
color = QColor( 0, 0, 0 );
width = 1;
if ( penJoinStyle )
*penJoinStyle = Qt::BevelJoin;
@@ -2224,7 +2224,7 @@ bool QgsSymbolLayerUtils::wellKnownMarkerFromSld( QDomElement &element,

name = QStringLiteral( "square" );
color = QColor();
strokeColor = QColor( "#000000" );
strokeColor = QColor( 0, 0, 0 );
strokeWidth = 1;
size = 6;

@@ -88,10 +88,10 @@ void QgsCodeEditor::setSciWidget()
{
setUtf8( true );
setCaretLineVisible( true );
setCaretLineBackgroundColor( QColor( "#fcf3ed" ) );
setCaretLineBackgroundColor( QColor( 252, 243, 237 ) );

setBraceMatching( QsciScintilla::SloppyBraceMatch );
setMatchedBraceBackgroundColor( QColor( "#b7f907" ) );
setMatchedBraceBackgroundColor( QColor( 183, 249, 7 ) );
// whether margin will be shown
setMarginVisible( mMargin );
// whether margin will be shown
@@ -121,8 +121,8 @@ void QgsCodeEditor::setMarginVisible( bool margin )
setMarginLineNumbers( 1, true );
setMarginsFont( marginFont );
setMarginWidth( 1, QStringLiteral( "00000" ) );
setMarginsForegroundColor( QColor( "#3E3EE3" ) );
setMarginsBackgroundColor( QColor( "#f9f9f9" ) );
setMarginsForegroundColor( QColor( 62, 62, 227 ) );
setMarginsBackgroundColor( QColor( 249, 249, 249 ) );
}
else
{
@@ -138,7 +138,7 @@ void QgsCodeEditor::setFoldingVisible( bool folding )
if ( folding )
{
setFolding( QsciScintilla::PlainFoldStyle );
setFoldMarginColors( QColor( "#f4f4f4" ), QColor( "#f4f4f4" ) );
setFoldMarginColors( QColor( 244, 244, 244 ), QColor( 244, 244, 244 ) );
}
else
{
@@ -43,7 +43,7 @@ void QgsCodeEditorPython::setSciLexerPython()

setEdgeMode( QsciScintilla::EdgeLine );
setEdgeColumn( 80 );
setEdgeColor( QColor( "#FF0000" ) );
setEdgeColor( QColor( 255, 0, 0 ) );

setWhitespaceVisibility( QsciScintilla::WsVisibleAfterIndent );

@@ -381,7 +381,7 @@ void QgsExpressionBuilderWidget::registerItem( const QString &group,
//Recent group should always be last group
newgroupNode->setData( group.startsWith( QLatin1String( "Recent (" ) ) ? 2 : 1, QgsExpressionItem::CUSTOM_SORT_ROLE );
newgroupNode->appendRow( item );
newgroupNode->setBackground( QBrush( QColor( "#eee" ) ) );
newgroupNode->setBackground( QBrush( QColor( 238, 238, 238 ) ) );
mModel->appendRow( newgroupNode );
mExpressionGroups.insert( group, newgroupNode );
}

0 comments on commit 5247478

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