Fix whitespace

This commit is contained in:
Nyall Dawson 2015-08-21 07:29:38 +10:00
parent 6a3357fab8
commit 9ce6b6b2b7
7 changed files with 416 additions and 390 deletions

View File

@ -22,6 +22,7 @@
find . -name "*.orig" -exec rm -rf {} \;
find . -name "*.prepare" -exec rm -rf {} \;
find . -name "astyle*.diff" -exec rm -rf {} \;
find . -name "*.astyle" -exec rm -rf {} \;
find . -name "sha*.diff" -exec rm -rf {} \;

View File

@ -18,7 +18,7 @@
#include "qgsnetworkaccessmanager.h"
QgsVersionInfo::QgsVersionInfo( QObject *parent ) : QObject(parent)
QgsVersionInfo::QgsVersionInfo( QObject *parent ) : QObject( parent )
{
}

View File

@ -1,144 +1,144 @@
#include <QPainter>
#include "qgsconditionalstyle.h"
#include "qgsexpression.h"
#include "qgsfontutils.h"
#include "qgssymbollayerv2utils.h"
#include "qgsmarkersymbollayerv2.h"
QgsConditionalStyle::QgsConditionalStyle()
: mValid( false )
, mSymbol( 0 )
{}
QgsConditionalStyle::QgsConditionalStyle( QString rule )
: mValid( false )
, mSymbol( 0 )
{
setRule( rule );
}
QgsConditionalStyle::QgsConditionalStyle( const QgsConditionalStyle &other )
: mValid( other.mValid )
, mRule( other.mRule )
, mFont( other.mFont )
, mBackColor( other.mBackColor )
, mTextColor( other.mTextColor )
, mIcon( other.mIcon )
{
if ( other.mSymbol.data() )
mSymbol.reset( other.mSymbol->clone() );
}
QgsConditionalStyle& QgsConditionalStyle::operator=( const QgsConditionalStyle & other )
{
mValid = other.mValid;
mRule = other.mRule;
mFont = other.mFont;
mBackColor = other.mBackColor;
mTextColor = other.mTextColor;
mIcon = other.mIcon;
if ( other.mSymbol.data() )
{
mSymbol.reset( other.mSymbol->clone() );
}
else
{
mSymbol.reset();
}
return ( *this );
}
QgsConditionalStyle::~QgsConditionalStyle()
{
}
void QgsConditionalStyle::setSymbol( QgsSymbolV2* value )
{
mValid = true;
if ( value )
{
mSymbol.reset( value->clone() );
mIcon = QgsSymbolLayerV2Utils::symbolPreviewPixmap( mSymbol.data(), QSize( 16, 16 ) );
}
else
{
mSymbol.reset();
}
}
bool QgsConditionalStyle::matches( QVariant value, QgsFeature *feature )
{
// TODO Replace with expression context
QgsExpression exp( QString( mRule ).replace( "@value", value.toString() ) );
if ( feature )
{
return exp.evaluate( feature, *feature->fields() ).toBool();
}
{
return exp.evaluate().toBool();
}
}
QPixmap QgsConditionalStyle::renderPreview()
{
QPixmap pixmap( 64, 32 );
QPainter painter( &pixmap );
if ( mBackColor.isValid() )
painter.setBrush( mBackColor );
else
painter.setBrush( QColor( Qt::white ) );
QRect rect = QRect( 0, 0, 64, 32 );
painter.setPen( Qt::NoPen );
painter.drawRect( rect );
painter.drawPixmap( 8, 8, icon() );
if ( mTextColor.isValid() )
painter.setPen( mTextColor );
else
painter.setPen( Qt::black );
painter.setRenderHint( QPainter::Antialiasing );
painter.setRenderHint( QPainter::HighQualityAntialiasing );
painter.setFont( font() );
rect = QRect( 32, 0, 32, 32 );
painter.drawText( rect, Qt::AlignCenter, "abc\n123" );
painter.end();
return pixmap;
}
bool QgsConditionalStyle::writeXml( QDomNode &node, QDomDocument &doc )
{
QDomElement stylesel = doc.createElement( "style" );
stylesel.setAttribute( "rule", mRule );
stylesel.setAttribute( "background_color", mBackColor.name() );
stylesel.setAttribute( "text_color", mTextColor.name() );
QDomElement labelFontElem = QgsFontUtils::toXmlElement( mFont, doc, "font" );
stylesel.appendChild( labelFontElem );
if ( ! mSymbol.isNull() )
{
QDomElement symbolElm = QgsSymbolLayerV2Utils::saveSymbol( "icon", mSymbol.data(), doc );
stylesel.appendChild( symbolElm );
}
node.appendChild( stylesel );
return true;
}
bool QgsConditionalStyle::readXml( const QDomNode &node )
{
QDomElement styleElm = node.toElement();
setRule( styleElm.attribute( "rule" ) );
setBackgroundColor( QColor( styleElm.attribute( "background_color" ) ) );
setTextColor( QColor( styleElm.attribute( "text_color" ) ) );
QgsFontUtils::setFromXmlChildNode( mFont, styleElm, "font" );
QDomElement symbolElm = styleElm.firstChildElement( "symbol" );
if ( !symbolElm.isNull() )
{
QgsSymbolV2* symbol = QgsSymbolLayerV2Utils::loadSymbol<QgsMarkerSymbolV2>( symbolElm );
setSymbol( symbol );
}
return true;
}
#include <QPainter>
#include "qgsconditionalstyle.h"
#include "qgsexpression.h"
#include "qgsfontutils.h"
#include "qgssymbollayerv2utils.h"
#include "qgsmarkersymbollayerv2.h"
QgsConditionalStyle::QgsConditionalStyle()
: mValid( false )
, mSymbol( 0 )
{}
QgsConditionalStyle::QgsConditionalStyle( QString rule )
: mValid( false )
, mSymbol( 0 )
{
setRule( rule );
}
QgsConditionalStyle::QgsConditionalStyle( const QgsConditionalStyle &other )
: mValid( other.mValid )
, mRule( other.mRule )
, mFont( other.mFont )
, mBackColor( other.mBackColor )
, mTextColor( other.mTextColor )
, mIcon( other.mIcon )
{
if ( other.mSymbol.data() )
mSymbol.reset( other.mSymbol->clone() );
}
QgsConditionalStyle& QgsConditionalStyle::operator=( const QgsConditionalStyle & other )
{
mValid = other.mValid;
mRule = other.mRule;
mFont = other.mFont;
mBackColor = other.mBackColor;
mTextColor = other.mTextColor;
mIcon = other.mIcon;
if ( other.mSymbol.data() )
{
mSymbol.reset( other.mSymbol->clone() );
}
else
{
mSymbol.reset();
}
return ( *this );
}
QgsConditionalStyle::~QgsConditionalStyle()
{
}
void QgsConditionalStyle::setSymbol( QgsSymbolV2* value )
{
mValid = true;
if ( value )
{
mSymbol.reset( value->clone() );
mIcon = QgsSymbolLayerV2Utils::symbolPreviewPixmap( mSymbol.data(), QSize( 16, 16 ) );
}
else
{
mSymbol.reset();
}
}
bool QgsConditionalStyle::matches( QVariant value, QgsFeature *feature )
{
// TODO Replace with expression context
QgsExpression exp( QString( mRule ).replace( "@value", value.toString() ) );
if ( feature )
{
return exp.evaluate( feature, *feature->fields() ).toBool();
}
{
return exp.evaluate().toBool();
}
}
QPixmap QgsConditionalStyle::renderPreview()
{
QPixmap pixmap( 64, 32 );
QPainter painter( &pixmap );
if ( mBackColor.isValid() )
painter.setBrush( mBackColor );
else
painter.setBrush( QColor( Qt::white ) );
QRect rect = QRect( 0, 0, 64, 32 );
painter.setPen( Qt::NoPen );
painter.drawRect( rect );
painter.drawPixmap( 8, 8, icon() );
if ( mTextColor.isValid() )
painter.setPen( mTextColor );
else
painter.setPen( Qt::black );
painter.setRenderHint( QPainter::Antialiasing );
painter.setRenderHint( QPainter::HighQualityAntialiasing );
painter.setFont( font() );
rect = QRect( 32, 0, 32, 32 );
painter.drawText( rect, Qt::AlignCenter, "abc\n123" );
painter.end();
return pixmap;
}
bool QgsConditionalStyle::writeXml( QDomNode &node, QDomDocument &doc )
{
QDomElement stylesel = doc.createElement( "style" );
stylesel.setAttribute( "rule", mRule );
stylesel.setAttribute( "background_color", mBackColor.name() );
stylesel.setAttribute( "text_color", mTextColor.name() );
QDomElement labelFontElem = QgsFontUtils::toXmlElement( mFont, doc, "font" );
stylesel.appendChild( labelFontElem );
if ( ! mSymbol.isNull() )
{
QDomElement symbolElm = QgsSymbolLayerV2Utils::saveSymbol( "icon", mSymbol.data(), doc );
stylesel.appendChild( symbolElm );
}
node.appendChild( stylesel );
return true;
}
bool QgsConditionalStyle::readXml( const QDomNode &node )
{
QDomElement styleElm = node.toElement();
setRule( styleElm.attribute( "rule" ) );
setBackgroundColor( QColor( styleElm.attribute( "background_color" ) ) );
setTextColor( QColor( styleElm.attribute( "text_color" ) ) );
QgsFontUtils::setFromXmlChildNode( mFont, styleElm, "font" );
QDomElement symbolElm = styleElm.firstChildElement( "symbol" );
if ( !symbolElm.isNull() )
{
QgsSymbolV2* symbol = QgsSymbolLayerV2Utils::loadSymbol<QgsMarkerSymbolV2>( symbolElm );
setSymbol( symbol );
}
return true;
}

View File

@ -1,131 +1,131 @@
#ifndef QGSCONDITIONALSTYLE_H
#define QGSCONDITIONALSTYLE_H
#include <QFont>
#include <QColor>
#include <QPixmap>
#include <QDomNode>
#include <QDomDocument>
#include "qgsfeature.h"
#include "qgssymbolv2.h"
/** \class QgsFieldFormat
* Conditional styling for a rule.
*/
class CORE_EXPORT QgsConditionalStyle
{
public:
QgsConditionalStyle();
QgsConditionalStyle( const QgsConditionalStyle& other );
QgsConditionalStyle( QString rule );
~QgsConditionalStyle();
QgsConditionalStyle& operator=( const QgsConditionalStyle& other );
/**
* @brief Check if the rule matches using the given value and feature
* @param value The current value being checked. \@value is replaced in the rule with this value.
* @param feature The feature to match the values from.
* @return True of the rule matches against the given feature
*/
bool matches( QVariant value, QgsFeature *feature = 0 );
/**
* @brief Render a preview icon of the rule.
* @return QPixmap preview of the style
*/
QPixmap renderPreview();
/**
* @brief Set the rule for the style. Rules should be of QgsExpression syntax.
* Special value of \@value is replaced at run time with the check value
* @param value The QgsExpression style rule to use for this style
*/
void setRule( QString value ) { mRule = value; mValid = true; }
/**
* @brief Set the background color for the style
* @param value QColor for background color
*/
void setBackgroundColor( QColor value ) { mBackColor = value; mValid = true; }
/**
* @brief Set the text color for the style
* @param value QColor for text color
*/
void setTextColor( QColor value ) { mTextColor = value; mValid = true; }
/**
* @brief Set the font for the the style
* @param value QFont to be used for text
*/
void setFont( QFont value ) { mFont = value; mValid = true; }
/**
* @brief Set the icon for the style. Icons are generated from symbols
* @param value QgsSymbolV2 to be used when generating the icon
*/
void setSymbol( QgsSymbolV2* value );
/**
* @brief The icon set for style generated from the set symbol
* @return A QPixmap that was set for the icon using the symbol
*/
QPixmap icon() const { return mIcon; }
/**
* @brief The symbol used to generate the icon for the style
* @return The QgsSymbolV2 used for the icon
*/
QgsSymbolV2* symbol() const { return mSymbol.data(); }
/**
* @brief The text color set for style
* @return QColor for text color
*/
QColor textColor() const { return mTextColor; }
/**
* @brief The background color for style
* @return QColor for background color
*/
QColor backgroundColor() const { return mBackColor; }
/**
* @brief The font for the style
* @return QFont for the style
*/
QFont font() const { return mFont; }
/**
* @brief The condtion rule set for the style. Rule may contain variable \@value
* to represent the current value
* @return QString of the current set rule
*/
QString rule() const { return mRule; }
/**
* @brief isValid Check if this rule is valid. A valid rule has one or more properties
* set.
* @return True if the rule is valid.
*/
bool isValid() const { return mValid; }
/** Reads vector conditional style specific state from layer Dom node.
*/
virtual bool readXml( const QDomNode& node );
/** Write vector conditional style specific state from layer Dom node.
*/
virtual bool writeXml( QDomNode & node, QDomDocument & doc );
bool mValid;
QString mRule;
QScopedPointer<QgsSymbolV2> mSymbol;
QFont mFont;
QColor mBackColor;
QColor mTextColor;
QPixmap mIcon;
};
#endif // QGSCONDITIONALSTYLE_H
#ifndef QGSCONDITIONALSTYLE_H
#define QGSCONDITIONALSTYLE_H
#include <QFont>
#include <QColor>
#include <QPixmap>
#include <QDomNode>
#include <QDomDocument>
#include "qgsfeature.h"
#include "qgssymbolv2.h"
/** \class QgsFieldFormat
* Conditional styling for a rule.
*/
class CORE_EXPORT QgsConditionalStyle
{
public:
QgsConditionalStyle();
QgsConditionalStyle( const QgsConditionalStyle& other );
QgsConditionalStyle( QString rule );
~QgsConditionalStyle();
QgsConditionalStyle& operator=( const QgsConditionalStyle& other );
/**
* @brief Check if the rule matches using the given value and feature
* @param value The current value being checked. \@value is replaced in the rule with this value.
* @param feature The feature to match the values from.
* @return True of the rule matches against the given feature
*/
bool matches( QVariant value, QgsFeature *feature = 0 );
/**
* @brief Render a preview icon of the rule.
* @return QPixmap preview of the style
*/
QPixmap renderPreview();
/**
* @brief Set the rule for the style. Rules should be of QgsExpression syntax.
* Special value of \@value is replaced at run time with the check value
* @param value The QgsExpression style rule to use for this style
*/
void setRule( QString value ) { mRule = value; mValid = true; }
/**
* @brief Set the background color for the style
* @param value QColor for background color
*/
void setBackgroundColor( QColor value ) { mBackColor = value; mValid = true; }
/**
* @brief Set the text color for the style
* @param value QColor for text color
*/
void setTextColor( QColor value ) { mTextColor = value; mValid = true; }
/**
* @brief Set the font for the the style
* @param value QFont to be used for text
*/
void setFont( QFont value ) { mFont = value; mValid = true; }
/**
* @brief Set the icon for the style. Icons are generated from symbols
* @param value QgsSymbolV2 to be used when generating the icon
*/
void setSymbol( QgsSymbolV2* value );
/**
* @brief The icon set for style generated from the set symbol
* @return A QPixmap that was set for the icon using the symbol
*/
QPixmap icon() const { return mIcon; }
/**
* @brief The symbol used to generate the icon for the style
* @return The QgsSymbolV2 used for the icon
*/
QgsSymbolV2* symbol() const { return mSymbol.data(); }
/**
* @brief The text color set for style
* @return QColor for text color
*/
QColor textColor() const { return mTextColor; }
/**
* @brief The background color for style
* @return QColor for background color
*/
QColor backgroundColor() const { return mBackColor; }
/**
* @brief The font for the style
* @return QFont for the style
*/
QFont font() const { return mFont; }
/**
* @brief The condtion rule set for the style. Rule may contain variable \@value
* to represent the current value
* @return QString of the current set rule
*/
QString rule() const { return mRule; }
/**
* @brief isValid Check if this rule is valid. A valid rule has one or more properties
* set.
* @return True if the rule is valid.
*/
bool isValid() const { return mValid; }
/** Reads vector conditional style specific state from layer Dom node.
*/
virtual bool readXml( const QDomNode& node );
/** Write vector conditional style specific state from layer Dom node.
*/
virtual bool writeXml( QDomNode & node, QDomDocument & doc );
bool mValid;
QString mRule;
QScopedPointer<QgsSymbolV2> mSymbol;
QFont mFont;
QColor mBackColor;
QColor mTextColor;
QPixmap mIcon;
};
#endif // QGSCONDITIONALSTYLE_H

View File

@ -1,56 +1,56 @@
#include <QDomElement>
#include "qgsconditionalstyle.h"
#include "qgsfielduiproperties.h"
QgsFieldUIProperties::QgsFieldUIProperties()
: mStyles( QList<QgsConditionalStyle>() )
{}
void QgsFieldUIProperties::setConditionalStyles( QList<QgsConditionalStyle> styles )
{
mStyles = styles;
}
QList<QgsConditionalStyle> QgsFieldUIProperties::getConditionalStyles()
{
return mStyles;
}
QgsConditionalStyle QgsFieldUIProperties::matchingConditionalStyle( QVariant value, QgsFeature *feature )
{
foreach ( QgsConditionalStyle style, mStyles )
{
if ( style.matches( value, feature ) )
return style;
}
return QgsConditionalStyle();
}
bool QgsFieldUIProperties::writeXml( QDomNode &node, QDomDocument &doc )
{
QDomElement stylesel = doc.createElement( "conditionalstyles" );
foreach ( QgsConditionalStyle style, mStyles )
{
style.writeXml( stylesel, doc );
}
node.appendChild( stylesel );
return true;
}
bool QgsFieldUIProperties::readXml( const QDomNode &node )
{
mStyles.clear();
QDomElement condel = node.firstChildElement( "conditionalstyles" );
QDomNodeList stylesList = condel.elementsByTagName( "style" );
for ( int i = 0; i < stylesList.size(); ++i )
{
QDomElement styleElm = stylesList.at( i ).toElement();
QgsConditionalStyle style = QgsConditionalStyle();
style.readXml( styleElm );
mStyles.append( style );
}
return true;
}
#include <QDomElement>
#include "qgsconditionalstyle.h"
#include "qgsfielduiproperties.h"
QgsFieldUIProperties::QgsFieldUIProperties()
: mStyles( QList<QgsConditionalStyle>() )
{}
void QgsFieldUIProperties::setConditionalStyles( QList<QgsConditionalStyle> styles )
{
mStyles = styles;
}
QList<QgsConditionalStyle> QgsFieldUIProperties::getConditionalStyles()
{
return mStyles;
}
QgsConditionalStyle QgsFieldUIProperties::matchingConditionalStyle( QVariant value, QgsFeature *feature )
{
foreach ( QgsConditionalStyle style, mStyles )
{
if ( style.matches( value, feature ) )
return style;
}
return QgsConditionalStyle();
}
bool QgsFieldUIProperties::writeXml( QDomNode &node, QDomDocument &doc )
{
QDomElement stylesel = doc.createElement( "conditionalstyles" );
foreach ( QgsConditionalStyle style, mStyles )
{
style.writeXml( stylesel, doc );
}
node.appendChild( stylesel );
return true;
}
bool QgsFieldUIProperties::readXml( const QDomNode &node )
{
mStyles.clear();
QDomElement condel = node.firstChildElement( "conditionalstyles" );
QDomNodeList stylesList = condel.elementsByTagName( "style" );
for ( int i = 0; i < stylesList.size(); ++i )
{
QDomElement styleElm = stylesList.at( i ).toElement();
QgsConditionalStyle style = QgsConditionalStyle();
style.readXml( styleElm );
mStyles.append( style );
}
return true;
}

View File

@ -1,56 +1,56 @@
#ifndef QGSFIELDUIPROPERTIES_H
#define QGSFIELDUIPROPERTIES_H
#include <QDomDocument>
#include <QDomNode>
#include "qgsfeature.h"
#include "qgsconditionalstyle.h"
/** \class QgsFieldUIProperties
* Holds extra UI properties for a field.
*
* Currently this object holds informations about condtional styles but in future will hold
* things like field widgets, etc
*
* TODO Move UI field related stuff from QgsVectorLayer here
*/
class CORE_EXPORT QgsFieldUIProperties
{
public:
QgsFieldUIProperties();
/**
* @brief Set the condtional styles for the field UI properties.
* @param styles
*/
void setConditionalStyles( QList<QgsConditionalStyle> styles );
/**
* @brief Returns the condtional styles set for the field UI properties
* @return A list of condtional styles that have been set.
*/
QList<QgsConditionalStyle> getConditionalStyles();
/**
* @brief Find and return the matching style for the value and feature.
* If no match is found a invalid QgsCondtionalStyle is return.
*
* @return A condtional style that matches the value and feature.
* Check with QgsCondtionalStyle::isValid()
*/
QgsConditionalStyle matchingConditionalStyle( QVariant value, QgsFeature* feature );
/** Reads field ui properties specific state from Dom node.
*/
virtual bool readXml( const QDomNode& node );
/** Write field ui properties specific state from Dom node.
*/
virtual bool writeXml( QDomNode & node, QDomDocument & doc );
private:
QList<QgsConditionalStyle> mStyles;
};
#endif // QGSFIELDUIPROPERTIES_H
#ifndef QGSFIELDUIPROPERTIES_H
#define QGSFIELDUIPROPERTIES_H
#include <QDomDocument>
#include <QDomNode>
#include "qgsfeature.h"
#include "qgsconditionalstyle.h"
/** \class QgsFieldUIProperties
* Holds extra UI properties for a field.
*
* Currently this object holds informations about condtional styles but in future will hold
* things like field widgets, etc
*
* TODO Move UI field related stuff from QgsVectorLayer here
*/
class CORE_EXPORT QgsFieldUIProperties
{
public:
QgsFieldUIProperties();
/**
* @brief Set the condtional styles for the field UI properties.
* @param styles
*/
void setConditionalStyles( QList<QgsConditionalStyle> styles );
/**
* @brief Returns the condtional styles set for the field UI properties
* @return A list of condtional styles that have been set.
*/
QList<QgsConditionalStyle> getConditionalStyles();
/**
* @brief Find and return the matching style for the value and feature.
* If no match is found a invalid QgsCondtionalStyle is return.
*
* @return A condtional style that matches the value and feature.
* Check with QgsCondtionalStyle::isValid()
*/
QgsConditionalStyle matchingConditionalStyle( QVariant value, QgsFeature* feature );
/** Reads field ui properties specific state from Dom node.
*/
virtual bool readXml( const QDomNode& node );
/** Write field ui properties specific state from Dom node.
*/
virtual bool writeXml( QDomNode & node, QDomDocument & doc );
private:
QList<QgsConditionalStyle> mStyles;
};
#endif // QGSFIELDUIPROPERTIES_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>380</width>
<height>336</height>
<width>410</width>
<height>337</height>
</rect>
</property>
<property name="sizePolicy">
@ -666,6 +666,31 @@
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mFieldCombo</tabstop>
<tabstop>listView</tabstop>
<tabstop>mNewButton</tabstop>
<tabstop>mRuleEdit</tabstop>
<tabstop>btnBuildExpression</tabstop>
<tabstop>mDefault1</tabstop>
<tabstop>mDefault3</tabstop>
<tabstop>mDefault2</tabstop>
<tabstop>pushButton_3</tabstop>
<tabstop>pushButton_8</tabstop>
<tabstop>pushButton_7</tabstop>
<tabstop>btnBackgroundColor</tabstop>
<tabstop>btnTextColor</tabstop>
<tabstop>checkIcon</tabstop>
<tabstop>btnChangeIcon</tabstop>
<tabstop>mFontBoldBtn</tabstop>
<tabstop>mFontItalicBtn</tabstop>
<tabstop>mFontUnderlineBtn</tabstop>
<tabstop>mFontStrikethroughBtn</tabstop>
<tabstop>mFontFamilyCmbBx</tabstop>
<tabstop>mSaveRule</tabstop>
<tabstop>mCancelButton</tabstop>
<tabstop>mDeleteButton</tabstop>
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
</resources>