Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QSvgSwitch Class Reference

#include <qsvgstructure_p.h>

Inheritance diagram for QSvgSwitch:
QSvgStructureNode QSvgNode

Public Functions

virtual void draw (QPainter *p, QSvgExtraStates &states)
 
 QSvgSwitch (QSvgNode *parent)
 
Type type () const
 
- Public Functions inherited from QSvgStructureNode
void addChild (QSvgNode *child, const QString &id)
 
virtual QRectF bounds (QPainter *p, QSvgExtraStates &states) const
 
QSvgNodepreviousSiblingNode (QSvgNode *n) const
 
 QSvgStructureNode (QSvgNode *parent)
 
QList< QSvgNode * > renderers () const
 
QSvgNodescopeNode (const QString &id) const
 
 ~QSvgStructureNode ()
 
- Public Functions inherited from QSvgNode
void appendStyleProperty (QSvgStyleProperty *prop, const QString &id)
 
void applyStyle (QPainter *p, QSvgExtraStates &states) const
 
DisplayMode displayMode () const
 
QSvgTinyDocumentdocument () const
 
bool isVisible () const
 
QString nodeId () const
 
QSvgNodeparent () const
 
 QSvgNode (QSvgNode *parent=0)
 
const QStringListrequiredExtensions () const
 
const QStringListrequiredFeatures () const
 
const QStringListrequiredFonts () const
 
const QStringListrequiredFormats () const
 
const QStringListrequiredLanguages () const
 
void revertStyle (QPainter *p, QSvgExtraStates &states) const
 
void setDisplayMode (DisplayMode display)
 
void setNodeId (const QString &i)
 
void setRequiredExtensions (const QStringList &lst)
 
void setRequiredFeatures (const QStringList &lst)
 
void setRequiredFonts (const QStringList &lst)
 
void setRequiredFormats (const QStringList &lst)
 
void setRequiredLanguages (const QStringList &lst)
 
void setVisible (bool visible)
 
void setXmlClass (const QString &str)
 
QSvgStylePropertystyleProperty (QSvgStyleProperty::Type type) const
 
QSvgFillStylePropertystyleProperty (const QString &id) const
 
virtual QRectF transformedBounds (QPainter *p, QSvgExtraStates &states) const
 
QRectF transformedBounds () const
 
QString xmlClass () const
 
virtual ~QSvgNode ()
 

Private Functions

void init ()
 

Properties

QString m_systemLanguage
 
QString m_systemLanguagePrefix
 

Additional Inherited Members

- Public Types inherited from QSvgNode
enum  DisplayMode {
  InlineMode, BlockMode, ListItemMode, RunInMode,
  CompactMode, MarkerMode, TableMode, InlineTableMode,
  TableRowGroupMode, TableHeaderGroupMode, TableFooterGroupMode, TableRowMode,
  TableColumnGroupMode, TableColumnMode, TableCellMode, TableCaptionMode,
  NoneMode, InheritMode
}
 
enum  Type {
  DOC, G, DEFS, SWITCH,
  ANIMATION, ARC, CIRCLE, ELLIPSE,
  IMAGE, LINE, PATH, POLYGON,
  POLYLINE, RECT, TEXT, TEXTAREA,
  TSPAN, USE, VIDEO
}
 
- Static Protected Functions inherited from QSvgNode
static qreal strokeWidth (QPainter *p)
 
- Protected Variables inherited from QSvgStructureNode
QList< QSvgStructureNode * > m_linkedScopes
 
QList< QSvgNode * > m_renderers
 
QHash< QString, QSvgNode * > m_scope
 
- Protected Variables inherited from QSvgNode
QSvgStyle m_style
 

Detailed Description

Definition at line 102 of file qsvgstructure_p.h.

Constructors and Destructors

◆ QSvgSwitch()

QSvgSwitch::QSvgSwitch ( QSvgNode parent)

Definition at line 277 of file qsvgstructure.cpp.

278  : QSvgStructureNode(parent)
279 {
280  init();
281 }
QSvgStructureNode(QSvgNode *parent)

Functions

◆ draw()

void QSvgSwitch::draw ( QPainter p,
QSvgExtraStates states 
)
virtual

Implements QSvgNode.

Definition at line 283 of file qsvgstructure.cpp.

284 {
286  applyStyle(p, states);
287 
288  while (itr != m_renderers.end()) {
289  QSvgNode *node = *itr;
290  if (node->isVisible() && (node->displayMode() != QSvgNode::NoneMode)) {
291  const QStringList &features = node->requiredFeatures();
292  const QStringList &extensions = node->requiredExtensions();
293  const QStringList &languages = node->requiredLanguages();
294  const QStringList &formats = node->requiredFormats();
295  const QStringList &fonts = node->requiredFonts();
296 
297  bool okToRender = true;
298  if (!features.isEmpty()) {
299  QStringList::const_iterator sitr = features.constBegin();
300  for (; sitr != features.constEnd(); ++sitr) {
301  if (!isSupportedSvgFeature(*sitr)) {
302  okToRender = false;
303  break;
304  }
305  }
306  }
307 
308  if (okToRender && !extensions.isEmpty()) {
309  QStringList::const_iterator sitr = extensions.constBegin();
310  for (; sitr != extensions.constEnd(); ++sitr) {
311  if (!isSupportedSvgExtension(*sitr)) {
312  okToRender = false;
313  break;
314  }
315  }
316  }
317 
318  if (okToRender && !languages.isEmpty()) {
319  QStringList::const_iterator sitr = languages.constBegin();
320  okToRender = false;
321  for (; sitr != languages.constEnd(); ++sitr) {
322  if ((*sitr).startsWith(m_systemLanguagePrefix)) {
323  okToRender = true;
324  break;
325  }
326  }
327  }
328 
329  if (okToRender && !formats.isEmpty()) {
330  okToRender = false;
331  }
332 
333  if (okToRender && !fonts.isEmpty()) {
334  okToRender = false;
335  }
336 
337  if (okToRender) {
338  node->draw(p, states);
339  break;
340  }
341  }
342  ++itr;
343  }
344  revertStyle(p, states);
345 }
const QStringList & requiredFormats() const
Definition: qsvgnode.cpp:280
const QStringList & requiredExtensions() const
Definition: qsvgnode.cpp:260
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
void applyStyle(QPainter *p, QSvgExtraStates &states) const
Definition: qsvgnode.cpp:118
Q_GUI_EXPORT QString extensions()
Definition: qegl.cpp:785
QString m_systemLanguagePrefix
static bool isSupportedSvgExtension(const QString &)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
const QStringList & requiredFeatures() const
Definition: qsvgnode.cpp:250
friend class const_iterator
Definition: qlist.h:264
bool isVisible() const
Definition: qsvgnode_p.h:188
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
DisplayMode displayMode() const
Definition: qsvgnode.cpp:330
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static bool isSupportedSvgFeature(const QString &str)
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181
const QStringList & requiredFonts() const
Definition: qsvgnode.cpp:290
const QStringList & requiredLanguages() const
Definition: qsvgnode.cpp:270
virtual void draw(QPainter *p, QSvgExtraStates &states)=0
void revertStyle(QPainter *p, QSvgExtraStates &states) const
Definition: qsvgnode.cpp:123
QList< QSvgNode * > m_renderers
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ init()

void QSvgSwitch::init ( )
private

Definition at line 352 of file qsvgstructure.cpp.

Referenced by QSvgSwitch().

353 {
354  QLocale locale;
355  m_systemLanguage = locale.name().replace(QLatin1Char('_'), QLatin1Char('-'));
356  int idx = m_systemLanguage.indexOf(QLatin1Char('-'));
358 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
QString name() const
Returns the language and country of this locale as a string of the form "language_country", where language is a lowercase, two-letter ISO 639 language code, and country is an uppercase, two- or three-letter ISO 3166 country code.
Definition: qlocale.cpp:963
QString m_systemLanguagePrefix
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
QString m_systemLanguage
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ type()

QSvgNode::Type QSvgSwitch::type ( ) const
virtual

Implements QSvgNode.

Definition at line 347 of file qsvgstructure.cpp.

348 {
349  return SWITCH;
350 }

Properties

◆ m_systemLanguage

QString QSvgSwitch::m_systemLanguage
private

Definition at line 111 of file qsvgstructure_p.h.

Referenced by init().

◆ m_systemLanguagePrefix

QString QSvgSwitch::m_systemLanguagePrefix
private

Definition at line 112 of file qsvgstructure_p.h.

Referenced by draw(), and init().


The documentation for this class was generated from the following files: