Qt 4.8
Public Functions | Properties | List of all members
QStyleSheetStyleSelector Class Reference
Inheritance diagram for QStyleSheetStyleSelector:
QCss::StyleSelector

Public Functions

QString attribute (NodePtr node, const QString &name) const
 
NodePtr duplicateNode (NodePtr node) const
 
void freeNode (NodePtr) const
 
bool hasAttributes (NodePtr) const
 
bool isNullNode (NodePtr node) const
 
QStringList nodeIds (NodePtr node) const
 
bool nodeNameEquals (NodePtr node, const QString &nodeName) const
 
QStringList nodeNames (NodePtr node) const
 
NodePtr parentNode (NodePtr node) const
 
NodePtr previousSiblingNode (NodePtr) const
 
 QStyleSheetStyleSelector ()
 
- Public Functions inherited from QCss::StyleSelector
QVector< DeclarationdeclarationsForNode (NodePtr node, const char *extraPseudo=0)
 
QVector< StyleRulestyleRulesForNode (NodePtr node)
 
 StyleSelector ()
 
virtual ~StyleSelector ()
 

Properties

QHash< const QWidget *, QHash< QString, QString > > m_attributeCache
 

Additional Inherited Members

- Public Variables inherited from QCss::StyleSelector
QString medium
 
Qt::CaseSensitivity nameCaseSensitivity
 
QVector< StyleSheetstyleSheets
 

Detailed Description

Definition at line 1421 of file qstylesheetstyle.cpp.

Constructors and Destructors

◆ QStyleSheetStyleSelector()

QStyleSheetStyleSelector::QStyleSheetStyleSelector ( )
inline

Definition at line 1424 of file qstylesheetstyle.cpp.

1424 { }

Functions

◆ attribute()

QString QStyleSheetStyleSelector::attribute ( NodePtr  node,
const QString name 
) const
inlinevirtual

Implements QCss::StyleSelector.

Definition at line 1442 of file qstylesheetstyle.cpp.

1443  {
1444  if (isNullNode(node))
1445  return QString();
1446 
1448  QHash<QString, QString>::const_iterator cacheIt = cache.constFind(name);
1449  if (cacheIt != cache.constEnd())
1450  return cacheIt.value();
1451 
1452  QVariant value = WIDGET(node)->property(name.toLatin1());
1453  if (!value.isValid()) {
1454  if (name == QLatin1String("class")) {
1455  QString className = QString::fromLatin1(WIDGET(node)->metaObject()->className());
1456  if (className.contains(QLatin1Char(':')))
1457  className.replace(QLatin1Char(':'), QLatin1Char('-'));
1458  cache[name] = className;
1459  return className;
1460  } else if (name == QLatin1String("style")) {
1461  QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(WIDGET(node)->style());
1462  if (proxy) {
1463  QString styleName = QString::fromLatin1(proxy->baseStyle()->metaObject()->className());
1464  cache[name] = styleName;
1465  return styleName;
1466  }
1467  }
1468  }
1469  QString valueStr;
1470  if(value.type() == QVariant::StringList || value.type() == QVariant::List)
1471  valueStr = value.toStringList().join(QLatin1String(" "));
1472  else
1473  valueStr = value.toString();
1474  cache[name] = valueStr;
1475  return valueStr;
1476  }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
T qobject_cast(QObject *object)
Definition: qobject.h:375
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
QStyle * baseStyle() const
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
const char * className
Definition: qwizard.cpp:137
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
const char * name
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:859
QHash< const QWidget *, QHash< QString, QString > > m_attributeCache
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
QString join(const QString &sep) const
Joins all the string list&#39;s strings into a single string with each element separated by the given sep...
Definition: qstringlist.h:162
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
#define WIDGET(x)
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
bool isNullNode(NodePtr node) const
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ duplicateNode()

NodePtr QStyleSheetStyleSelector::duplicateNode ( NodePtr  node) const
inlinevirtual

Implements QCss::StyleSelector.

Definition at line 1510 of file qstylesheetstyle.cpp.

1511  { return node; }

◆ freeNode()

void QStyleSheetStyleSelector::freeNode ( NodePtr  ) const
inlinevirtual

Implements QCss::StyleSelector.

Definition at line 1512 of file qstylesheetstyle.cpp.

1513  { }

◆ hasAttributes()

bool QStyleSheetStyleSelector::hasAttributes ( NodePtr  ) const
inlinevirtual

Implements QCss::StyleSelector.

Definition at line 1500 of file qstylesheetstyle.cpp.

1501  { return true; }

◆ isNullNode()

bool QStyleSheetStyleSelector::isNullNode ( NodePtr  node) const
inlinevirtual

Implements QCss::StyleSelector.

Definition at line 1504 of file qstylesheetstyle.cpp.

1505  { return node.ptr == 0; }

◆ nodeIds()

QStringList QStyleSheetStyleSelector::nodeIds ( NodePtr  node) const
inlinevirtual

Reimplemented from QCss::StyleSelector.

Definition at line 1502 of file qstylesheetstyle.cpp.

1503  { return isNullNode(node) ? QStringList() : QStringList(WIDGET(node)->objectName()); }
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
#define WIDGET(x)
bool isNullNode(NodePtr node) const

◆ nodeNameEquals()

bool QStyleSheetStyleSelector::nodeNameEquals ( NodePtr  node,
const QString nodeName 
) const
inlinevirtual

Reimplemented from QCss::StyleSelector.

Definition at line 1477 of file qstylesheetstyle.cpp.

1478  {
1479  if (isNullNode(node))
1480  return false;
1481  const QMetaObject *metaObject = WIDGET(node)->metaObject();
1482 #ifndef QT_NO_TOOLTIP
1483  if (qstrcmp(metaObject->className(), "QTipLabel") == 0)
1484  return nodeName == QLatin1String("QToolTip");
1485 #endif
1486  do {
1487  const ushort *uc = (const ushort *)nodeName.constData();
1488  const ushort *e = uc + nodeName.length();
1489  const uchar *c = (uchar *)metaObject->className();
1490  while (*c && uc != e && (*uc == *c || (*c == ':' && *uc == '-'))) {
1491  ++uc;
1492  ++c;
1493  }
1494  if (uc == e && !*c)
1495  return true;
1496  metaObject = metaObject->superClass();
1497  } while (metaObject != 0);
1498  return false;
1499  }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
unsigned char c[8]
Definition: qnumeric_p.h:62
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
unsigned char uchar
Definition: qglobal.h:994
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or 0 if there is no such object.
Definition: qobjectdefs.h:494
unsigned short ushort
Definition: qglobal.h:995
#define WIDGET(x)
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336
bool isNullNode(NodePtr node) const
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ nodeNames()

QStringList QStyleSheetStyleSelector::nodeNames ( NodePtr  node) const
inlinevirtual

Implements QCss::StyleSelector.

Definition at line 1426 of file qstylesheetstyle.cpp.

1427  {
1428  if (isNullNode(node))
1429  return QStringList();
1430  const QMetaObject *metaObject = WIDGET(node)->metaObject();
1431 #ifndef QT_NO_TOOLTIP
1432  if (qstrcmp(metaObject->className(), "QTipLabel") == 0)
1433  return QStringList(QLatin1String("QToolTip"));
1434 #endif
1435  QStringList result;
1436  do {
1437  result += QString::fromLatin1(metaObject->className()).replace(QLatin1Char(':'), QLatin1Char('-'));
1438  metaObject = metaObject->superClass();
1439  } while (metaObject != 0);
1440  return result;
1441  }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or 0 if there is no such object.
Definition: qobjectdefs.h:494
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
#define WIDGET(x)
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336
bool isNullNode(NodePtr node) const
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parentNode()

NodePtr QStyleSheetStyleSelector::parentNode ( NodePtr  node) const
inlinevirtual

Implements QCss::StyleSelector.

Definition at line 1506 of file qstylesheetstyle.cpp.

1507  { NodePtr n; n.ptr = isNullNode(node) ? 0 : parentWidget(WIDGET(node)); return n; }
static QWidget * parentWidget(const QWidget *w)
#define WIDGET(x)
bool isNullNode(NodePtr node) const

◆ previousSiblingNode()

NodePtr QStyleSheetStyleSelector::previousSiblingNode ( NodePtr  ) const
inlinevirtual

Implements QCss::StyleSelector.

Definition at line 1508 of file qstylesheetstyle.cpp.

1509  { NodePtr n; n.ptr = 0; return n; }

Properties

◆ m_attributeCache

QHash<const QWidget *, QHash<QString, QString> > QStyleSheetStyleSelector::m_attributeCache
mutableprivate

Definition at line 1516 of file qstylesheetstyle.cpp.


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