Qt 4.8
Classes | Public Functions | Public Variables | List of all members
QCss::Declaration Struct Reference

#include <qcssparser_p.h>

Classes

struct  DeclarationData
 

Public Functions

Qt::Alignment alignmentValue () const
 
Attachment attachmentValue () const
 
void borderImageValue (QString *image, int *cuts, TileMode *h, TileMode *v) const
 
QBrush brushValue (const QPalette &=QPalette()) const
 
void brushValues (QBrush *c, const QPalette &=QPalette()) const
 
QColor colorValue (const QPalette &=QPalette()) const
 
void colorValues (QColor *c, const QPalette &=QPalette()) const
 
 Declaration ()
 
QIcon iconValue () const
 
bool intValue (int *i, const char *unit=0) const
 
bool isEmpty () const
 
Origin originValue () const
 
PositionMode positionValue () const
 
bool realValue (qreal *r, const char *unit=0) const
 
QRect rectValue () const
 
Repeat repeatValue () const
 
QSize sizeValue () const
 
int styleFeaturesValue () const
 
BorderStyle styleValue () const
 
void styleValues (BorderStyle *s) const
 
QString uriValue () const
 

Public Variables

QExplicitlySharedDataPointer< DeclarationDatad
 

Detailed Description

Definition at line 419 of file qcssparser_p.h.

Constructors and Destructors

◆ Declaration()

QCss::Declaration::Declaration ( )
inline

Definition at line 431 of file qcssparser_p.h.

431 : d(new DeclarationData()) {}
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430

Functions

◆ alignmentValue()

Qt::Alignment Declaration::alignmentValue ( ) const

Definition at line 1597 of file qcssparser.cpp.

Referenced by QCss::ValueExtractor::extractBackground(), QCss::ValueExtractor::extractImage(), QCss::ValueExtractor::extractPosition(), and QRenderRule::QRenderRule().

1598 {
1599  if (d->parsed.isValid())
1600  return Qt::Alignment(d->parsed.toInt());
1601  if (d->values.isEmpty() || d->values.count() > 2)
1602  return Qt::AlignLeft | Qt::AlignTop;
1603 
1604  Qt::Alignment v = parseAlignment(d->values.constData(), d->values.count());
1605  d->parsed = int(v);
1606  return v;
1607 }
static Qt::Alignment parseAlignment(const QCss::Value *values, int count)
Definition: qcssparser.cpp:652
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430

◆ attachmentValue()

Attachment Declaration::attachmentValue ( ) const

Definition at line 1564 of file qcssparser.cpp.

Referenced by QCss::ValueExtractor::extractBackground().

1565 {
1566  if (d->parsed.isValid())
1567  return static_cast<Attachment>(d->parsed.toInt());
1568  if (d->values.count() != 1)
1569  return Attachment_Unknown;
1570  int v = findKnownValue(d->values.at(0).variant.toString(),
1572  d->parsed = v;
1573  return static_cast<Attachment>(v);
1574 }
static const QCssKnownValue attachments[NumKnownAttachments - 1]
Definition: qcssparser.cpp:336
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static quint64 findKnownValue(const QString &name, const QCssKnownValue *start, int numValues)
Definition: qcssparser.cpp:357

◆ borderImageValue()

void Declaration::borderImageValue ( QString image,
int *  cuts,
TileMode h,
TileMode v 
) const

Definition at line 1609 of file qcssparser.cpp.

Referenced by QRenderRule::QRenderRule().

1611 {
1612  *image = uriValue();
1613  for (int i = 0; i < 4; i++)
1614  cuts[i] = -1;
1615  *h = *v = TileMode_Stretch;
1616 
1617  if (d->values.count() < 2)
1618  return;
1619 
1620  if (d->values.at(1).type == Value::Number) { // cuts!
1621  int i;
1622  for (i = 0; i < qMin(d->values.count()-1, 4); i++) {
1623  const Value& v = d->values.at(i+1);
1624  if (v.type != Value::Number)
1625  break;
1626  cuts[i] = v.variant.toString().toInt();
1627  }
1628  if (i == 0) cuts[0] = cuts[1] = cuts[2] = cuts[3] = 0;
1629  else if (i == 1) cuts[3] = cuts[2] = cuts[1] = cuts[0];
1630  else if (i == 2) cuts[2] = cuts[0], cuts[3] = cuts[1];
1631  else if (i == 3) cuts[3] = cuts[1];
1632  }
1633 
1634  if (d->values.last().type == Value::Identifier) {
1635  *v = static_cast<TileMode>(findKnownValue(d->values.last().variant.toString(),
1637  }
1638  if (d->values[d->values.count() - 2].type == Value::Identifier) {
1639  *h = static_cast<TileMode>
1640  (findKnownValue(d->values[d->values.count()-2].variant.toString(),
1642  } else
1643  *h = *v;
1644 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
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
static quint64 findKnownValue(const QString &name, const QCssKnownValue *start, int numValues)
Definition: qcssparser.cpp:357
QString uriValue() const
static const QCssKnownValue tileModes[NumKnownTileModes - 1]
Definition: qcssparser.cpp:323

◆ brushValue()

QBrush Declaration::brushValue ( const QPalette pal = QPalette()) const

Definition at line 1325 of file qcssparser.cpp.

Referenced by QCss::ValueExtractor::extractBackground(), QCss::ValueExtractor::extractBorder(), QCss::ValueExtractor::extractPalette(), and QStyleSheetStyle::setProperties().

1326 {
1327  if (d->values.count() != 1)
1328  return QBrush();
1329 
1330  if (d->parsed.isValid()) {
1331  if (d->parsed.type() == QVariant::Brush)
1332  return qvariant_cast<QBrush>(d->parsed);
1333  if (d->parsed.type() == QVariant::Int)
1334  return pal.color((QPalette::ColorRole)(d->parsed.toInt()));
1335  }
1336 
1337  BrushData data = parseBrushValue(d->values.at(0), pal);
1338 
1339  if(data.type == BrushData::Role) {
1340  d->parsed = QVariant::fromValue<int>(data.role);
1341  return pal.color((QPalette::ColorRole)(data.role));
1342  } else {
1344  d->parsed = QVariant::fromValue<QBrush>(data.brush);
1345  return data.brush;
1346  }
1347 }
QPalette::ColorRole role
Definition: qcssparser_p.h:390
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
enum QCss::BrushData::@265 type
static BrushData parseBrushValue(const QCss::Value &v, const QPalette &pal)
Definition: qcssparser.cpp:741
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static const char * data(const QByteArray &arr)
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76

◆ brushValues()

void Declaration::brushValues ( QBrush c,
const QPalette pal = QPalette() 
) const

Definition at line 1349 of file qcssparser.cpp.

Referenced by QCss::ValueExtractor::extractBorder(), and QCss::ValueExtractor::extractOutline().

1350 {
1351  int needParse = 0x1f; // bits 0..3 say if we should parse the corresponding value.
1352  // the bit 4 say we need to update d->parsed
1353  int i = 0;
1354  if (d->parsed.isValid()) {
1355  needParse = 0;
1356  QList<QVariant> v = d->parsed.toList();
1357  for (i = 0; i < qMin(v.count(), 4); i++) {
1358  if (v.at(i).type() == QVariant::Brush) {
1359  c[i] = qvariant_cast<QBrush>(v.at(i));
1360  } else if (v.at(i).type() == QVariant::Int) {
1361  c[i] = pal.color((QPalette::ColorRole)(v.at(i).toInt()));
1362  } else {
1363  needParse |= (1<<i);
1364  }
1365  }
1366  }
1367  if (needParse != 0) {
1368  QList<QVariant> v;
1369  for (i = 0; i < qMin(d->values.count(), 4); i++) {
1370  if (!(needParse & (1<<i)))
1371  continue;
1372  BrushData data = parseBrushValue(d->values.at(i), pal);
1373  if(data.type == BrushData::Role) {
1374  v += QVariant::fromValue<int>(data.role);
1375  c[i] = pal.color((QPalette::ColorRole)(data.role));
1376  } else {
1377  if (data.type != BrushData::DependsOnThePalette) {
1378  v += QVariant::fromValue<QBrush>(data.brush);
1379  } else {
1380  v += QVariant();
1381  }
1382  c[i] = data.brush;
1383  }
1384  }
1385  if (needParse & 0x10)
1386  d->parsed = v;
1387  }
1388  if (i == 0) c[0] = c[1] = c[2] = c[3] = QBrush();
1389  else if (i == 1) c[3] = c[2] = c[1] = c[0];
1390  else if (i == 2) c[2] = c[0], c[3] = c[1];
1391  else if (i == 3) c[3] = c[1];
1392 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QPalette::ColorRole role
Definition: qcssparser_p.h:390
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
enum QCss::BrushData::@265 type
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static BrushData parseBrushValue(const QCss::Value &v, const QPalette &pal)
Definition: qcssparser.cpp:741
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
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 const char * data(const QByteArray &arr)
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ colorValue()

QColor Declaration::colorValue ( const QPalette pal = QPalette()) const

Definition at line 1303 of file qcssparser.cpp.

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

1304 {
1305  if (d->values.count() != 1)
1306  return QColor();
1307 
1308  if (d->parsed.isValid()) {
1309  if (d->parsed.type() == QVariant::Color)
1310  return qvariant_cast<QColor>(d->parsed);
1311  if (d->parsed.type() == QVariant::Int)
1312  return pal.color((QPalette::ColorRole)(d->parsed.toInt()));
1313  }
1314 
1315  ColorData color = parseColorValue(d->values.at(0));
1316  if(color.type == ColorData::Role) {
1317  d->parsed = QVariant::fromValue<int>(color.role);
1318  return pal.color((QPalette::ColorRole)(color.role));
1319  } else {
1320  d->parsed = QVariant::fromValue<QColor>(color.color);
1321  return color.color;
1322  }
1323 }
QPalette::ColorRole role
Definition: qcssparser_p.h:381
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static ColorData parseColorValue(QCss::Value v)
Definition: qcssparser.cpp:675
enum QCss::ColorData::@264 type

◆ colorValues()

void Declaration::colorValues ( QColor c,
const QPalette pal = QPalette() 
) const

Definition at line 1477 of file qcssparser.cpp.

1478 {
1479  int i;
1480  if (d->parsed.isValid()) {
1481  QList<QVariant> v = d->parsed.toList();
1482  for (i = 0; i < qMin(d->values.count(), 4); i++) {
1483  if (v.at(i).type() == QVariant::Color) {
1484  c[i] = qvariant_cast<QColor>(v.at(i));
1485  } else {
1486  c[i] = pal.color((QPalette::ColorRole)(v.at(i).toInt()));
1487  }
1488  }
1489  } else {
1490  QList<QVariant> v;
1491  for (i = 0; i < qMin(d->values.count(), 4); i++) {
1492  ColorData color = parseColorValue(d->values.at(i));
1493  if(color.type == ColorData::Role) {
1494  v += QVariant::fromValue<int>(color.role);
1495  c[i] = pal.color((QPalette::ColorRole)(color.role));
1496  } else {
1497  v += QVariant::fromValue<QColor>(color.color);
1498  c[i] = color.color;
1499  }
1500  }
1501  d->parsed = v;
1502  }
1503 
1504  if (i == 0) c[0] = c[1] = c[2] = c[3] = QColor();
1505  else if (i == 1) c[3] = c[2] = c[1] = c[0];
1506  else if (i == 2) c[2] = c[0], c[3] = c[1];
1507  else if (i == 3) c[3] = c[1];
1508 }
QPalette::ColorRole role
Definition: qcssparser_p.h:381
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
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 ColorData parseColorValue(QCss::Value v)
Definition: qcssparser.cpp:675
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
enum QCss::ColorData::@264 type
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ iconValue()

QIcon Declaration::iconValue ( ) const

Definition at line 1646 of file qcssparser.cpp.

Referenced by QCss::ValueExtractor::extractImage(), QRenderRule::QRenderRule(), and QStyleSheetStyle::setProperties().

1647 {
1648  if (d->parsed.isValid())
1649  return qvariant_cast<QIcon>(d->parsed);
1650 
1651  QIcon icon;
1652  for (int i = 0; i < d->values.count();) {
1653  const Value &value = d->values.at(i++);
1654  if (value.type != Value::Uri)
1655  break;
1656  QString uri = value.variant.toString();
1657  QIcon::Mode mode = QIcon::Normal;
1658  QIcon::State state = QIcon::Off;
1659  for (int j = 0; j < 2; j++) {
1660  if (i != d->values.count() && d->values.at(i).type == Value::KnownIdentifier) {
1661  switch (d->values.at(i).variant.toInt()) {
1662  case Value_Disabled: mode = QIcon::Disabled; break;
1663  case Value_Active: mode = QIcon::Active; break;
1664  case Value_Selected: mode = QIcon::Selected; break;
1665  case Value_Normal: mode = QIcon::Normal; break;
1666  case Value_On: state = QIcon::On; break;
1667  case Value_Off: state = QIcon::Off; break;
1668  default: break;
1669  }
1670  ++i;
1671  } else {
1672  break;
1673  }
1674  }
1675 
1676  // QIcon is soo broken
1677  if (icon.isNull())
1678  icon = QIcon(uri);
1679  else
1680  icon.addPixmap(uri, mode, state);
1681 
1682  if (i == d->values.count())
1683  break;
1684 
1685  if (d->values.at(i).type == Value::TermOperatorComma)
1686  i++;
1687  }
1688 
1689  d->parsed = QVariant::fromValue<QIcon>(icon);
1690  return icon;
1691 }
void addPixmap(const QPixmap &pixmap, Mode mode=Normal, State state=Off)
Adds pixmap to the icon, as a specialization for mode and state.
Definition: qicon.cpp:814
State
This enum describes the state for which a pixmap is intended to be used.
Definition: qicon.h:64
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
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ intValue()

bool Declaration::intValue ( int *  i,
const char *  unit = 0 
) const

Definition at line 1431 of file qcssparser.cpp.

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

1432 {
1433  if (d->values.count() != 1)
1434  return false;
1435  return intValueHelper(d->values.at(0), i, unit);
1436 }
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static bool intValueHelper(const QCss::Value &v, int *i, const char *unit)

◆ isEmpty()

bool QCss::Declaration::isEmpty ( ) const
inline

Definition at line 432 of file qcssparser_p.h.

Referenced by QCss::Parser::parsePage(), and QCss::Parser::parseRuleset().

432 { return d->property.isEmpty() && d->propertyId == UnknownProperty; }
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430

◆ originValue()

Origin Declaration::originValue ( ) const

Definition at line 1540 of file qcssparser.cpp.

Referenced by QCss::ValueExtractor::extractBackground(), and QCss::ValueExtractor::extractPosition().

1541 {
1542  if (d->parsed.isValid())
1543  return static_cast<Origin>(d->parsed.toInt());
1544  if (d->values.count() != 1)
1545  return Origin_Unknown;
1546  int v = findKnownValue(d->values.at(0).variant.toString(),
1548  d->parsed = v;
1549  return static_cast<Origin>(v);
1550 }
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static const QCssKnownValue origins[NumKnownOrigins - 1]
Definition: qcssparser.cpp:309
static quint64 findKnownValue(const QString &name, const QCssKnownValue *start, int numValues)
Definition: qcssparser.cpp:357

◆ positionValue()

PositionMode Declaration::positionValue ( ) const

Definition at line 1552 of file qcssparser.cpp.

Referenced by QCss::ValueExtractor::extractPosition().

1553 {
1554  if (d->parsed.isValid())
1555  return static_cast<PositionMode>(d->parsed.toInt());
1556  if (d->values.count() != 1)
1557  return PositionMode_Unknown;
1558  int v = findKnownValue(d->values.at(0).variant.toString(),
1560  d->parsed = v;
1561  return static_cast<PositionMode>(v);
1562 }
PositionMode
Definition: qcssparser_p.h:331
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Definition: qcssparser.cpp:329
static quint64 findKnownValue(const QString &name, const QCssKnownValue *start, int numValues)
Definition: qcssparser.cpp:357

◆ realValue()

bool Declaration::realValue ( qreal r,
const char *  unit = 0 
) const

Definition at line 1394 of file qcssparser.cpp.

Referenced by QTextHtmlParserNode::applyCssDeclarations().

1395 {
1396  if (d->values.count() != 1)
1397  return false;
1398  const Value &v = d->values.at(0);
1399  if (unit && v.type != Value::Length)
1400  return false;
1401  QString s = v.variant.toString();
1402  if (unit) {
1404  return false;
1405  s.chop(qstrlen(unit));
1406  }
1407  bool ok = false;
1408  qreal val = s.toDouble(&ok);
1409  if (ok)
1410  *real = val;
1411  return ok;
1412 }
double qreal
Definition: qglobal.h:1193
void chop(int n)
Removes n characters from the end of the string.
Definition: qstring.cpp:4623
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
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
uint qstrlen(const char *str)
Definition: qbytearray.h:79
double toDouble(bool *ok=0) const
Returns the string converted to a double value.
Definition: qstring.cpp:6227
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

◆ rectValue()

QRect Declaration::rectValue ( ) const

Definition at line 1455 of file qcssparser.cpp.

Referenced by QStyleSheetStyle::setProperties().

1456 {
1457  if (d->values.count() != 1)
1458  return QRect();
1459 
1460  if (d->parsed.isValid())
1461  return qvariant_cast<QRect>(d->parsed);
1462 
1463  const QCss::Value &v = d->values.at(0);
1464  if (v.type != Value::Function)
1465  return QRect();
1466  QStringList func = v.variant.toStringList();
1467  if (func.count() != 2 || func.at(0).compare(QLatin1String("rect")) != 0)
1468  return QRect();
1469  QStringList args = func[1].split(QLatin1Char(' '), QString::SkipEmptyParts);
1470  if (args.count() != 4)
1471  return QRect();
1472  QRect rect(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt());
1473  d->parsed = QVariant::fromValue<QRect>(rect);
1474  return rect;
1475 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QVariant variant
Definition: qcssparser_p.h:372
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static int toInt(const QByteArray &str)
Definition: generator.cpp:167
int compare(const QString &s) const
Definition: qstring.cpp:5037
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ repeatValue()

Repeat Declaration::repeatValue ( ) const

Definition at line 1528 of file qcssparser.cpp.

1529 {
1530  if (d->parsed.isValid())
1531  return static_cast<Repeat>(d->parsed.toInt());
1532  if (d->values.count() != 1)
1533  return Repeat_Unknown;
1534  int v = findKnownValue(d->values.at(0).variant.toString(),
1536  d->parsed = v;
1537  return static_cast<Repeat>(v);
1538 }
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static quint64 findKnownValue(const QString &name, const QCssKnownValue *start, int numValues)
Definition: qcssparser.cpp:357
static const QCssKnownValue repeats[NumKnownRepeats - 1]
Definition: qcssparser.cpp:316

◆ sizeValue()

QSize Declaration::sizeValue ( ) const

Definition at line 1438 of file qcssparser.cpp.

Referenced by QRenderRule::QRenderRule(), and QStyleSheetStyle::setProperties().

1439 {
1440  if (d->parsed.isValid())
1441  return qvariant_cast<QSize>(d->parsed);
1442 
1443  int x[2] = { 0, 0 };
1444  if (d->values.count() > 0)
1445  intValueHelper(d->values.at(0), &x[0], "px");
1446  if (d->values.count() > 1)
1447  intValueHelper(d->values.at(1), &x[1], "px");
1448  else
1449  x[1] = x[0];
1450  QSize size(x[0], x[1]);
1451  d->parsed = QVariant::fromValue<QSize>(size);
1452  return size;
1453 }
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static bool intValueHelper(const QCss::Value &v, int *i, const char *unit)
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ styleFeaturesValue()

int Declaration::styleFeaturesValue ( ) const

Definition at line 1576 of file qcssparser.cpp.

Referenced by QCss::ValueExtractor::extractStyleFeatures().

1577 {
1578  Q_ASSERT(d->propertyId == QtStyleFeatures);
1579  if (d->parsed.isValid())
1580  return d->parsed.toInt();
1581  int features = StyleFeature_None;
1582  for (int i = 0; i < d->values.count(); i++) {
1583  features |= static_cast<int>(findKnownValue(d->values.value(i).variant.toString(),
1585  }
1586  d->parsed = features;
1587  return features;
1588 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static quint64 findKnownValue(const QString &name, const QCssKnownValue *start, int numValues)
Definition: qcssparser.cpp:357
static const QCssKnownValue styleFeatures[NumKnownStyleFeatures - 1]
Definition: qcssparser.cpp:341

◆ styleValue()

BorderStyle Declaration::styleValue ( ) const

Definition at line 1510 of file qcssparser.cpp.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), and QCss::ValueExtractor::extractBorder().

1511 {
1512  if (d->values.count() != 1)
1513  return BorderStyle_None;
1514  return parseStyleValue(d->values.at(0));
1515 }
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static BorderStyle parseStyleValue(QCss::Value v)
Definition: qcssparser.cpp:859

◆ styleValues()

void Declaration::styleValues ( BorderStyle s) const

Definition at line 1517 of file qcssparser.cpp.

Referenced by QCss::ValueExtractor::extractBorder(), and QCss::ValueExtractor::extractOutline().

1518 {
1519  int i;
1520  for (i = 0; i < qMin(d->values.count(), 4); i++)
1521  s[i] = parseStyleValue(d->values.at(i));
1522  if (i == 0) s[0] = s[1] = s[2] = s[3] = BorderStyle_None;
1523  else if (i == 1) s[3] = s[2] = s[1] = s[0];
1524  else if (i == 2) s[2] = s[0], s[3] = s[1];
1525  else if (i == 3) s[3] = s[1];
1526 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
static BorderStyle parseStyleValue(QCss::Value v)
Definition: qcssparser.cpp:859

◆ uriValue()

QString Declaration::uriValue ( ) const

Definition at line 1590 of file qcssparser.cpp.

Referenced by QStyleSheetStyle::setProperties().

1591 {
1592  if (d->values.isEmpty() || d->values.at(0).type != Value::Uri)
1593  return QString();
1594  return d->values.at(0).variant.toString();
1595 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430

Properties

◆ d


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