~josephjamesmills/ubuntu-ui-toolkit/QtCreator_Help_Plugins

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/plugin/itemstyleattached.cpp

[theming] Building selector for a styled item moved into Selector class.

Previous functionality present in ItemStyleAttachedPrivate::updateStyleSelector() was moved into Selector class, class being responsible of building up the selectors from different sources.

A selector can now be built up from a QQuickItem, in which case the item becomes the owner of the selector. Any additional update on the selector made by calling update() method will fetch the latest information from the owner and update the last node of the selector.

Approved by PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
220
220
 
221
221
bool ItemStyleAttachedPrivate::updateStyleSelector()
222
222
{
223
 
    Selector path;
224
 
    SelectorNode::Relationship relation = SelectorNode::Child;
225
 
    QQuickItem *parent = attachee->parentItem();
226
 
    ItemStyleAttached *parentStyle = 0;
227
 
 
228
 
    path << SelectorNode(QuickUtils::instance().className(attachee).toLower(), styleClass, styleId, SelectorNode::Descendant);
229
 
 
230
 
    while (parent) {
231
 
        parentStyle = ThemeEnginePrivate::attachedStyle(parent);
232
 
        if (!parentStyle)
233
 
            relation = SelectorNode::Descendant;
234
 
        else {
235
 
            path[0] = SelectorNode(path[0].type(), path[0].getClass(), path[0].id(), relation);
236
 
            path.prepend(
237
 
                        SelectorNode(QuickUtils::instance().className(parentStyle->d_ptr->attachee),
238
 
                                     parentStyle->d_ptr->styleClass,
239
 
                                     parentStyle->d_ptr->styleId,
240
 
                                     SelectorNode::Descendant)
241
 
                        );
242
 
            relation = SelectorNode::Child;
243
 
        }
244
 
        parent = parent->parentItem();
245
 
    }
 
223
    Selector path(attachee);
246
224
 
247
225
    if (path != styleSelector) {
248
226
        styleSelector = path;
415
393
    if (!customStyle || !customDelegate) {
416
394
        if (!connectedToEngine) {
417
395
            connectedToEngine = (bool)QObject::connect(ThemeEngine::instance(), SIGNAL(themeChanged()), q, SLOT(_q_refreshStyle()));
418
 
            updateStyleSelector();
419
396
        }
420
397
    } else {
421
398
        if (connectedToEngine)