Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QCss::ValueExtractor Struct Reference

#include <qcssparser_p.h>

Public Functions

bool extractBackground (QBrush *, QString *, Repeat *, Qt::Alignment *, QCss::Origin *, QCss::Attachment *, QCss::Origin *)
 
bool extractBorder (int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii)
 
bool extractBox (int *margins, int *paddings, int *spacing=0)
 
bool extractFont (QFont *font, int *fontSizeAdjustment)
 
bool extractGeometry (int *w, int *h, int *minw, int *minh, int *maxw, int *maxh)
 
bool extractImage (QIcon *icon, Qt::Alignment *a, QSize *size)
 
bool extractOutline (int *borders, QBrush *colors, BorderStyle *Styles, QSize *radii, int *offsets)
 
bool extractPalette (QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg)
 
bool extractPosition (int *l, int *t, int *r, int *b, QCss::Origin *, Qt::Alignment *, QCss::PositionMode *, Qt::Alignment *)
 
int extractStyleFeatures ()
 
int lengthValue (const Declaration &decl)
 
 ValueExtractor (const QVector< Declaration > &declarations, const QPalette &=QPalette())
 

Private Functions

void borderValue (const Declaration &decl, int *width, QCss::BorderStyle *style, QBrush *color)
 
void extractFont ()
 
LengthData lengthValue (const Value &v)
 
void lengthValues (const Declaration &decl, int *m)
 
QSize sizeValue (const Declaration &decl)
 
void sizeValues (const Declaration &decl, QSize *radii)
 

Properties

int adjustment
 
QVector< Declarationdeclarations
 
QFont f
 
int fontExtracted
 
QPalette pal
 

Detailed Description

Definition at line 568 of file qcssparser_p.h.

Constructors and Destructors

◆ ValueExtractor()

ValueExtractor::ValueExtractor ( const QVector< Declaration > &  declarations,
const QPalette pal = QPalette() 
)

Definition at line 368 of file qcssparser.cpp.

369 : declarations(decls), adjustment(0), fontExtracted(false), pal(pal)
370 {
371 }
QVector< Declaration > declarations
Definition: qcssparser_p.h:595

Functions

◆ borderValue()

void ValueExtractor::borderValue ( const Declaration decl,
int *  width,
QCss::BorderStyle style,
QBrush color 
)
private

Definition at line 895 of file qcssparser.cpp.

Referenced by extractBorder(), and extractOutline().

896 {
897  if (decl.d->parsed.isValid()) {
898  BorderData data = qvariant_cast<BorderData>(decl.d->parsed);
899  *width = lengthValueFromData(data.width, f);
900  *style = data.style;
901  *color = data.color.type != BrushData::Invalid ? brushFromData(data.color, pal) : QBrush(QColor());
902  return;
903  }
904 
905  *width = 0;
906  *style = BorderStyle_None;
907  *color = QColor();
908 
909  if (decl.d->values.isEmpty())
910  return;
911 
913  data.width.number = 0;
914  data.width.unit = LengthData::None;
915  data.style = BorderStyle_None;
916 
917  int i = 0;
918  if (decl.d->values.at(i).type == Value::Length || decl.d->values.at(i).type == Value::Number) {
919  data.width = lengthValue(decl.d->values.at(i));
920  *width = lengthValueFromData(data.width, f);
921  if (++i >= decl.d->values.count()) {
922  decl.d->parsed = QVariant::fromValue<BorderData>(data);
923  return;
924  }
925  }
926 
927  data.style = parseStyleValue(decl.d->values.at(i));
928  if (data.style != BorderStyle_Unknown) {
929  *style = data.style;
930  if (++i >= decl.d->values.count()) {
931  decl.d->parsed = QVariant::fromValue<BorderData>(data);
932  return;
933  }
934  } else {
935  data.style = BorderStyle_None;
936  }
937 
938  data.color = parseBrushValue(decl.d->values.at(i), pal);
939  *color = brushFromData(data.color, pal);
941  decl.d->parsed = QVariant::fromValue<BorderData>(data);
942 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
int lengthValue(const Declaration &decl)
Definition: qcssparser.cpp:402
enum QCss::BrushData::@265 type
LengthData width
Definition: qcssparser_p.h:407
static BrushData parseBrushValue(const QCss::Value &v, const QPalette &pal)
Definition: qcssparser.cpp:741
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static BorderStyle parseStyleValue(QCss::Value v)
Definition: qcssparser.cpp:859
BorderStyle style
Definition: qcssparser_p.h:408
static const char * data(const QByteArray &arr)
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
enum QCss::LengthData::@266 unit
static int lengthValueFromData(const LengthData &data, const QFont &f)
Definition: qcssparser.cpp:393
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
static QBrush brushFromData(const BrushData &c, const QPalette &pal)
Definition: qcssparser.cpp:850

◆ extractBackground()

bool ValueExtractor::extractBackground ( QBrush brush,
QString image,
Repeat repeat,
Qt::Alignment *  alignment,
QCss::Origin origin,
QCss::Attachment attachment,
QCss::Origin clip 
)

Definition at line 990 of file qcssparser.cpp.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), and QRenderRule::QRenderRule().

993 {
994  bool hit = false;
995  for (int i = 0; i < declarations.count(); ++i) {
996  const Declaration &decl = declarations.at(i);
997  if (decl.d->values.isEmpty())
998  continue;
999  const QCss::Value &val = decl.d->values.at(0);
1000  switch (decl.d->propertyId) {
1001  case BackgroundColor:
1002  *brush = decl.brushValue();
1003  break;
1004  case BackgroundImage:
1005  if (val.type == Value::Uri)
1006  *image = val.variant.toString();
1007  break;
1008  case BackgroundRepeat:
1009  if (decl.d->parsed.isValid()) {
1010  *repeat = static_cast<Repeat>(decl.d->parsed.toInt());
1011  } else {
1012  *repeat = static_cast<Repeat>(findKnownValue(val.variant.toString(),
1014  decl.d->parsed = *repeat;
1015  }
1016  break;
1017  case BackgroundPosition:
1018  *alignment = decl.alignmentValue();
1019  break;
1020  case BackgroundOrigin:
1021  *origin = decl.originValue();
1022  break;
1023  case BackgroundClip:
1024  *clip = decl.originValue();
1025  break;
1026  case Background:
1027  if (decl.d->parsed.isValid()) {
1029  *brush = brushFromData(data.brush, pal);
1030  *image = data.image;
1031  *repeat = data.repeat;
1032  *alignment = data.alignment;
1033  } else {
1034  BrushData brushData;
1035  parseShorthandBackgroundProperty(decl.d->values, &brushData, image, repeat, alignment, pal);
1036  *brush = brushFromData(brushData, pal);
1037  if (brushData.type != BrushData::DependsOnThePalette) {
1038  BackgroundData data = { brushData, *image, *repeat, *alignment };
1039  decl.d->parsed = QVariant::fromValue<BackgroundData>(data);
1040  }
1041  }
1042  break;
1043  case BackgroundAttachment:
1044  *attachment = decl.attachmentValue();
1045  break;
1046  default: continue;
1047  }
1048  hit = true;
1049  }
1050  return hit;
1051 }
static void parseShorthandBackgroundProperty(const QVector< QCss::Value > &values, BrushData *brush, QString *image, Repeat *repeat, Qt::Alignment *alignment, const QPalette &pal)
Definition: qcssparser.cpp:944
QVector< Declaration > declarations
Definition: qcssparser_p.h:595
enum QCss::BrushData::@265 type
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QVariant variant
Definition: qcssparser_p.h:372
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
Attachment attachmentValue() const
static const char * data(const QByteArray &arr)
static quint64 findKnownValue(const QString &name, const QCssKnownValue *start, int numValues)
Definition: qcssparser.cpp:357
QBrush brushValue(const QPalette &=QPalette()) const
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
Qt::Alignment alignment
Definition: qcssparser_p.h:398
Origin originValue() const
static const QCssKnownValue repeats[NumKnownRepeats - 1]
Definition: qcssparser.cpp:316
static QBrush brushFromData(const BrushData &c, const QPalette &pal)
Definition: qcssparser.cpp:850
Qt::Alignment alignmentValue() const

◆ extractBorder()

bool ValueExtractor::extractBorder ( int *  borders,
QBrush colors,
BorderStyle Styles,
QSize radii 
)

Definition at line 559 of file qcssparser.cpp.

Referenced by QRenderRule::QRenderRule().

561 {
562  extractFont();
563  bool hit = false;
564  for (int i = 0; i < declarations.count(); i++) {
565  const Declaration &decl = declarations.at(i);
566  switch (decl.d->propertyId) {
567  case BorderLeftWidth: borders[LeftEdge] = lengthValue(decl); break;
568  case BorderRightWidth: borders[RightEdge] = lengthValue(decl); break;
569  case BorderTopWidth: borders[TopEdge] = lengthValue(decl); break;
570  case BorderBottomWidth: borders[BottomEdge] = lengthValue(decl); break;
571  case BorderWidth: lengthValues(decl, borders); break;
572 
573  case BorderLeftColor: colors[LeftEdge] = decl.brushValue(pal); break;
574  case BorderRightColor: colors[RightEdge] = decl.brushValue(pal); break;
575  case BorderTopColor: colors[TopEdge] = decl.brushValue(pal); break;
576  case BorderBottomColor: colors[BottomEdge] = decl.brushValue(pal); break;
577  case BorderColor: decl.brushValues(colors, pal); break;
578 
579  case BorderTopStyle: styles[TopEdge] = decl.styleValue(); break;
580  case BorderBottomStyle: styles[BottomEdge] = decl.styleValue(); break;
581  case BorderLeftStyle: styles[LeftEdge] = decl.styleValue(); break;
582  case BorderRightStyle: styles[RightEdge] = decl.styleValue(); break;
583  case BorderStyles: decl.styleValues(styles); break;
584 
585  case BorderTopLeftRadius: radii[0] = sizeValue(decl); break;
586  case BorderTopRightRadius: radii[1] = sizeValue(decl); break;
587  case BorderBottomLeftRadius: radii[2] = sizeValue(decl); break;
588  case BorderBottomRightRadius: radii[3] = sizeValue(decl); break;
589  case BorderRadius: sizeValues(decl, radii); break;
590 
591  case BorderLeft:
592  borderValue(decl, &borders[LeftEdge], &styles[LeftEdge], &colors[LeftEdge]);
593  break;
594  case BorderTop:
595  borderValue(decl, &borders[TopEdge], &styles[TopEdge], &colors[TopEdge]);
596  break;
597  case BorderRight:
598  borderValue(decl, &borders[RightEdge], &styles[RightEdge], &colors[RightEdge]);
599  break;
600  case BorderBottom:
601  borderValue(decl, &borders[BottomEdge], &styles[BottomEdge], &colors[BottomEdge]);
602  break;
603  case Border:
604  borderValue(decl, &borders[LeftEdge], &styles[LeftEdge], &colors[LeftEdge]);
605  borders[TopEdge] = borders[RightEdge] = borders[BottomEdge] = borders[LeftEdge];
606  styles[TopEdge] = styles[RightEdge] = styles[BottomEdge] = styles[LeftEdge];
607  colors[TopEdge] = colors[RightEdge] = colors[BottomEdge] = colors[LeftEdge];
608  break;
609 
610  default: continue;
611  }
612  hit = true;
613  }
614 
615  return hit;
616 }
QVector< Declaration > declarations
Definition: qcssparser_p.h:595
int lengthValue(const Declaration &decl)
Definition: qcssparser.cpp:402
void lengthValues(const Declaration &decl, int *m)
Definition: qcssparser.cpp:413
void styleValues(BorderStyle *s) const
void brushValues(QBrush *c, const QPalette &=QPalette()) const
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
void sizeValues(const Declaration &decl, QSize *radii)
Definition: qcssparser.cpp:552
QSize sizeValue(const Declaration &decl)
Definition: qcssparser.cpp:531
QBrush brushValue(const QPalette &=QPalette()) const
void borderValue(const Declaration &decl, int *width, QCss::BorderStyle *style, QBrush *color)
Definition: qcssparser.cpp:895
BorderStyle styleValue() const

◆ extractBox()

bool ValueExtractor::extractBox ( int *  margins,
int *  paddings,
int *  spacing = 0 
)

Definition at line 492 of file qcssparser.cpp.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), and QRenderRule::QRenderRule().

493 {
494  extractFont();
495  bool hit = false;
496  for (int i = 0; i < declarations.count(); i++) {
497  const Declaration &decl = declarations.at(i);
498  switch (decl.d->propertyId) {
499  case PaddingLeft: paddings[LeftEdge] = lengthValue(decl); break;
500  case PaddingRight: paddings[RightEdge] = lengthValue(decl); break;
501  case PaddingTop: paddings[TopEdge] = lengthValue(decl); break;
502  case PaddingBottom: paddings[BottomEdge] = lengthValue(decl); break;
503  case Padding: lengthValues(decl, paddings); break;
504 
505  case MarginLeft: margins[LeftEdge] = lengthValue(decl); break;
506  case MarginRight: margins[RightEdge] = lengthValue(decl); break;
507  case MarginTop: margins[TopEdge] = lengthValue(decl); break;
508  case MarginBottom: margins[BottomEdge] = lengthValue(decl); break;
509  case Margin: lengthValues(decl, margins); break;
510  case QtSpacing: if (spacing) *spacing = lengthValue(decl); break;
511 
512  default: continue;
513  }
514  hit = true;
515  }
516 
517  return hit;
518 }
QVector< Declaration > declarations
Definition: qcssparser_p.h:595
int lengthValue(const Declaration &decl)
Definition: qcssparser.cpp:402
void lengthValues(const Declaration &decl, int *m)
Definition: qcssparser.cpp:413
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430

◆ extractFont() [1/2]

bool ValueExtractor::extractFont ( QFont font,
int *  fontSizeAdjustment 
)

Definition at line 1216 of file qcssparser.cpp.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), and QRenderRule::QRenderRule().

1217 {
1218  if (fontExtracted) {
1219  *font = f;
1220  *fontSizeAdjustment = adjustment;
1221  return fontExtracted == 1;
1222  }
1223 
1224  bool hit = false;
1225  for (int i = 0; i < declarations.count(); ++i) {
1226  const Declaration &decl = declarations.at(i);
1227  if (decl.d->values.isEmpty())
1228  continue;
1229  const QCss::Value &val = decl.d->values.at(0);
1230  switch (decl.d->propertyId) {
1231  case FontSize: setFontSizeFromValue(val, font, fontSizeAdjustment); break;
1232  case FontStyle: setFontStyleFromValue(val, font); break;
1233  case FontWeight: setFontWeightFromValue(val, font); break;
1234  case FontFamily: setFontFamilyFromValues(decl.d->values, font); break;
1235  case TextDecoration: setTextDecorationFromValues(decl.d->values, font); break;
1236  case Font: parseShorthandFontProperty(decl.d->values, font, fontSizeAdjustment); break;
1237  case FontVariant: setFontVariantFromValue(val, font); break;
1238  case TextTransform: setTextTransformFromValue(val, font); break;
1239  default: continue;
1240  }
1241  hit = true;
1242  }
1243 
1244  f = *font;
1245  adjustment = *fontSizeAdjustment;
1246  fontExtracted = hit ? 1 : 2;
1247  return hit;
1248 }
QVector< Declaration > declarations
Definition: qcssparser_p.h:595
static bool setFontFamilyFromValues(const QVector< QCss::Value > &values, QFont *font, int start=0)
static bool setFontStyleFromValue(const QCss::Value &value, QFont *font)
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static void setTextTransformFromValue(const QCss::Value &value, QFont *font)
static void setTextDecorationFromValues(const QVector< QCss::Value > &values, QFont *font)
static void parseShorthandFontProperty(const QVector< QCss::Value > &values, QFont *font, int *fontSizeAdjustment)
static bool setFontSizeFromValue(QCss::Value value, QFont *font, int *fontSizeAdjustment)
static bool setFontWeightFromValue(const QCss::Value &value, QFont *font)
static void setFontVariantFromValue(const QCss::Value &value, QFont *font)

◆ extractFont() [2/2]

void ValueExtractor::extractFont ( )
private

Definition at line 1267 of file qcssparser.cpp.

Referenced by extractBorder(), extractBox(), extractGeometry(), extractOutline(), and extractPosition().

1268 {
1269  if (fontExtracted)
1270  return;
1271  int dummy = -255;
1272  extractFont(&f, &dummy);
1273 }

◆ extractGeometry()

bool ValueExtractor::extractGeometry ( int *  w,
int *  h,
int *  minw,
int *  minh,
int *  maxw,
int *  maxh 
)

Definition at line 447 of file qcssparser.cpp.

Referenced by QRenderRule::QRenderRule().

448 {
449  extractFont();
450  bool hit = false;
451  for (int i = 0; i < declarations.count(); i++) {
452  const Declaration &decl = declarations.at(i);
453  switch (decl.d->propertyId) {
454  case Width: *w = lengthValue(decl); break;
455  case Height: *h = lengthValue(decl); break;
456  case MinimumWidth: *minw = lengthValue(decl); break;
457  case MinimumHeight: *minh = lengthValue(decl); break;
458  case MaximumWidth: *maxw = lengthValue(decl); break;
459  case MaximumHeight: *maxh = lengthValue(decl); break;
460  default: continue;
461  }
462  hit = true;
463  }
464 
465  return hit;
466 }
QVector< Declaration > declarations
Definition: qcssparser_p.h:595
int lengthValue(const Declaration &decl)
Definition: qcssparser.cpp:402
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430

◆ extractImage()

bool ValueExtractor::extractImage ( QIcon icon,
Qt::Alignment *  a,
QSize size 
)

Definition at line 1275 of file qcssparser.cpp.

Referenced by QRenderRule::QRenderRule().

1276 {
1277  bool hit = false;
1278  for (int i = 0; i < declarations.count(); ++i) {
1279  const Declaration &decl = declarations.at(i);
1280  switch (decl.d->propertyId) {
1281  case QtImage:
1282  *icon = decl.iconValue();
1283  if (decl.d->values.count() > 0 && decl.d->values.at(0).type == Value::Uri) {
1284  // try to pull just the size from the image...
1285  QImageReader imageReader(decl.d->values.at(0).variant.toString());
1286  if ((*size = imageReader.size()).isNull()) {
1287  // but we'll have to load the whole image if the
1288  // format doesn't support just reading the size
1289  *size = imageReader.read().size();
1290  }
1291  }
1292  break;
1293  case QtImageAlignment: *a = decl.alignmentValue(); break;
1294  default: continue;
1295  }
1296  hit = true;
1297  }
1298  return hit;
1299 }
QVector< Declaration > declarations
Definition: qcssparser_p.h:595
long ASN1_INTEGER_get ASN1_INTEGER * a
QIcon iconValue() const
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
The QImageReader class provides a format independent interface for reading images from files or other...
Definition: qimagereader.h:62
Qt::Alignment alignmentValue() const
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300

◆ extractOutline()

bool ValueExtractor::extractOutline ( int *  borders,
QBrush colors,
BorderStyle Styles,
QSize radii,
int *  offsets 
)

Definition at line 618 of file qcssparser.cpp.

Referenced by QRenderRule::QRenderRule().

620 {
621  extractFont();
622  bool hit = false;
623  for (int i = 0; i < declarations.count(); i++) {
624  const Declaration &decl = declarations.at(i);
625  switch (decl.d->propertyId) {
626  case OutlineWidth: lengthValues(decl, borders); break;
627  case OutlineColor: decl.brushValues(colors, pal); break;
628  case OutlineStyle: decl.styleValues(styles); break;
629 
630  case OutlineTopLeftRadius: radii[0] = sizeValue(decl); break;
631  case OutlineTopRightRadius: radii[1] = sizeValue(decl); break;
632  case OutlineBottomLeftRadius: radii[2] = sizeValue(decl); break;
633  case OutlineBottomRightRadius: radii[3] = sizeValue(decl); break;
634  case OutlineRadius: sizeValues(decl, radii); break;
635  case OutlineOffset: lengthValues(decl, offsets); break;
636 
637  case Outline:
638  borderValue(decl, &borders[LeftEdge], &styles[LeftEdge], &colors[LeftEdge]);
639  borders[TopEdge] = borders[RightEdge] = borders[BottomEdge] = borders[LeftEdge];
640  styles[TopEdge] = styles[RightEdge] = styles[BottomEdge] = styles[LeftEdge];
641  colors[TopEdge] = colors[RightEdge] = colors[BottomEdge] = colors[LeftEdge];
642  break;
643 
644  default: continue;
645  }
646  hit = true;
647  }
648 
649  return hit;
650 }
QVector< Declaration > declarations
Definition: qcssparser_p.h:595
void lengthValues(const Declaration &decl, int *m)
Definition: qcssparser.cpp:413
void styleValues(BorderStyle *s) const
void brushValues(QBrush *c, const QPalette &=QPalette()) const
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
void sizeValues(const Declaration &decl, QSize *radii)
Definition: qcssparser.cpp:552
QSize sizeValue(const Declaration &decl)
Definition: qcssparser.cpp:531
void borderValue(const Declaration &decl, int *width, QCss::BorderStyle *style, QBrush *color)
Definition: qcssparser.cpp:895

◆ extractPalette()

bool ValueExtractor::extractPalette ( QBrush fg,
QBrush sfg,
QBrush sbg,
QBrush abg 
)

Definition at line 1250 of file qcssparser.cpp.

Referenced by QRenderRule::QRenderRule().

1251 {
1252  bool hit = false;
1253  for (int i = 0; i < declarations.count(); ++i) {
1254  const Declaration &decl = declarations.at(i);
1255  switch (decl.d->propertyId) {
1256  case Color: *fg = decl.brushValue(pal); break;
1257  case QtSelectionForeground: *sfg = decl.brushValue(pal); break;
1258  case QtSelectionBackground: *sbg = decl.brushValue(pal); break;
1259  case QtAlternateBackground: *abg = decl.brushValue(pal); break;
1260  default: continue;
1261  }
1262  hit = true;
1263  }
1264  return hit;
1265 }
QVector< Declaration > declarations
Definition: qcssparser_p.h:595
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
QBrush brushValue(const QPalette &=QPalette()) const

◆ extractPosition()

bool ValueExtractor::extractPosition ( int *  l,
int *  t,
int *  r,
int *  b,
QCss::Origin origin,
Qt::Alignment *  position,
QCss::PositionMode mode,
Qt::Alignment *  textAlignment 
)

Definition at line 468 of file qcssparser.cpp.

Referenced by QRenderRule::QRenderRule().

470 {
471  extractFont();
472  bool hit = false;
473  for (int i = 0; i < declarations.count(); i++) {
474  const Declaration &decl = declarations.at(i);
475  switch (decl.d->propertyId) {
476  case Left: *left = lengthValue(decl); break;
477  case Top: *top = lengthValue(decl); break;
478  case Right: *right = lengthValue(decl); break;
479  case Bottom: *bottom = lengthValue(decl); break;
480  case QtOrigin: *origin = decl.originValue(); break;
481  case QtPosition: *position = decl.alignmentValue(); break;
482  case TextAlignment: *textAlignment = decl.alignmentValue(); break;
483  case Position: *mode = decl.positionValue(); break;
484  default: continue;
485  }
486  hit = true;
487  }
488 
489  return hit;
490 }
QVector< Declaration > declarations
Definition: qcssparser_p.h:595
int lengthValue(const Declaration &decl)
Definition: qcssparser.cpp:402
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
PositionMode positionValue() const
Origin originValue() const
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
Qt::Alignment alignmentValue() const

◆ extractStyleFeatures()

int ValueExtractor::extractStyleFeatures ( )

Definition at line 520 of file qcssparser.cpp.

Referenced by QRenderRule::QRenderRule().

521 {
522  int features = StyleFeature_None;
523  for (int i = 0; i < declarations.count(); i++) {
524  const Declaration &decl = declarations.at(i);
525  if (decl.d->propertyId == QtStyleFeatures)
526  features = decl.styleFeaturesValue();
527  }
528  return features;
529 }
QVector< Declaration > declarations
Definition: qcssparser_p.h:595
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
int styleFeaturesValue() const

◆ lengthValue() [1/2]

int ValueExtractor::lengthValue ( const Declaration decl)

Definition at line 402 of file qcssparser.cpp.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), borderValue(), extractBorder(), extractBox(), extractGeometry(), extractPosition(), lengthValues(), and sizeValue().

403 {
404  if (decl.d->parsed.isValid())
405  return lengthValueFromData(qvariant_cast<LengthData>(decl.d->parsed), f);
406  if (decl.d->values.count() < 1)
407  return 0;
408  LengthData data = lengthValue(decl.d->values.at(0));
409  decl.d->parsed = QVariant::fromValue<LengthData>(data);
410  return lengthValueFromData(data,f);
411 }
int lengthValue(const Declaration &decl)
Definition: qcssparser.cpp:402
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static const char * data(const QByteArray &arr)
static int lengthValueFromData(const LengthData &data, const QFont &f)
Definition: qcssparser.cpp:393

◆ lengthValue() [2/2]

LengthData ValueExtractor::lengthValue ( const Value v)
private

Definition at line 373 of file qcssparser.cpp.

374 {
375  QString s = v.variant.toString();
376  s.reserve(s.length());
378  data.unit = LengthData::None;
380  data.unit = LengthData::Px;
382  data.unit = LengthData::Ex;
384  data.unit = LengthData::Em;
385 
386  if (data.unit != LengthData::None)
387  s.chop(2);
388 
389  data.number = s.toDouble();
390  return data;
391 }
void chop(int n)
Removes n characters from the end of the string.
Definition: qstring.cpp:4623
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
The QString class provides a Unicode character string.
Definition: qstring.h:83
QVariant variant
Definition: qcssparser_p.h:372
void reserve(int size)
Attempts to allocate memory for at least size characters.
Definition: qstring.h:881
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
enum QCss::LengthData::@266 unit
double toDouble(bool *ok=0) const
Returns the string converted to a double value.
Definition: qstring.cpp:6227
if(void) toggleToolbarShown
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796

◆ lengthValues()

void ValueExtractor::lengthValues ( const Declaration decl,
int *  m 
)
private

Definition at line 413 of file qcssparser.cpp.

Referenced by extractBorder(), extractBox(), and extractOutline().

414 {
415  if (decl.d->parsed.isValid()) {
416  QList<QVariant> v = decl.d->parsed.toList();
417  for (int i = 0; i < 4; i++)
418  m[i] = lengthValueFromData(qvariant_cast<LengthData>(v.at(i)), f);
419  return;
420  }
421 
422  LengthData datas[4];
423  int i;
424  for (i = 0; i < qMin(decl.d->values.count(), 4); i++)
425  datas[i] = lengthValue(decl.d->values[i]);
426 
427  if (i == 0) {
429  datas[0] = datas[1] = datas[2] = datas[3] = zero;
430  } else if (i == 1) {
431  datas[3] = datas[2] = datas[1] = datas[0];
432  } else if (i == 2) {
433  datas[2] = datas[0];
434  datas[3] = datas[1];
435  } else if (i == 3) {
436  datas[3] = datas[1];
437  }
438 
439  QList<QVariant> v;
440  for (i = 0; i < 4; i++) {
441  v += QVariant::fromValue<LengthData>(datas[i]);
442  m[i] = lengthValueFromData(datas[i], f);
443  }
444  decl.d->parsed = v;
445 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int lengthValue(const Declaration &decl)
Definition: qcssparser.cpp:402
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static int lengthValueFromData(const LengthData &data, const QFont &f)
Definition: qcssparser.cpp:393
static const int zero

◆ sizeValue()

QSize ValueExtractor::sizeValue ( const Declaration decl)
private

Definition at line 531 of file qcssparser.cpp.

Referenced by extractBorder(), extractOutline(), and sizeValues().

532 {
533  if (decl.d->parsed.isValid()) {
534  QList<QVariant> v = decl.d->parsed.toList();
535  return QSize(lengthValueFromData(qvariant_cast<LengthData>(v.at(0)), f),
536  lengthValueFromData(qvariant_cast<LengthData>(v.at(1)), f));
537  }
538 
539  LengthData x[2] = { {0, LengthData::None }, {0, LengthData::None} };
540  if (decl.d->values.count() > 0)
541  x[0] = lengthValue(decl.d->values.at(0));
542  if (decl.d->values.count() > 1)
543  x[1] = lengthValue(decl.d->values.at(1));
544  else
545  x[1] = x[0];
546  QList<QVariant> v;
547  v << QVariant::fromValue<LengthData>(x[0]) << qVariantFromValue<LengthData>(x[1]);
548  decl.d->parsed = v;
549  return QSize(lengthValueFromData(x[0], f), lengthValueFromData(x[1], f));
550 }
int lengthValue(const Declaration &decl)
Definition: qcssparser.cpp:402
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static int lengthValueFromData(const LengthData &data, const QFont &f)
Definition: qcssparser.cpp:393
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ sizeValues()

void ValueExtractor::sizeValues ( const Declaration decl,
QSize radii 
)
private

Definition at line 552 of file qcssparser.cpp.

Referenced by extractBorder(), and extractOutline().

553 {
554  radii[0] = sizeValue(decl);
555  for (int i = 1; i < 4; i++)
556  radii[i] = radii[0];
557 }
QSize sizeValue(const Declaration &decl)
Definition: qcssparser.cpp:531

Properties

◆ adjustment

int QCss::ValueExtractor::adjustment
private

Definition at line 597 of file qcssparser_p.h.

Referenced by extractFont().

◆ declarations

QVector<Declaration> QCss::ValueExtractor::declarations
private

◆ f

QFont QCss::ValueExtractor::f
private

Definition at line 596 of file qcssparser_p.h.

Referenced by borderValue(), extractFont(), lengthValue(), lengthValues(), and sizeValue().

◆ fontExtracted

int QCss::ValueExtractor::fontExtracted
private

Definition at line 598 of file qcssparser_p.h.

Referenced by extractFont().

◆ pal

QPalette QCss::ValueExtractor::pal
private

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