~zsombi/ubuntu-ui-toolkit/50-custom-delegates

« back to all changes in this revision

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

prereq sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
UCListItemAttachedPrivate::~UCListItemAttachedPrivate()
38
38
{
39
39
    clearChangesList();
40
 
    clearFlickableList();
 
40
    clearFlickablesList();
41
41
}
42
42
 
43
43
// disconnect all flickables
44
 
void UCListItemAttachedPrivate::clearFlickableList()
 
44
void UCListItemAttachedPrivate::clearFlickablesList()
45
45
{
46
46
    Q_Q(UCListItemAttached);
47
47
    Q_FOREACH(const QPointer<QQuickFlickable> &flickable, flickables) {
51
51
    }
52
52
    flickables.clear();
53
53
}
 
54
 
54
55
// connect all flickables
55
56
void UCListItemAttachedPrivate::buildFlickablesList()
56
57
{
59
60
    if (!item) {
60
61
        return;
61
62
    }
62
 
    clearFlickableList();
 
63
    clearFlickablesList();
63
64
    while (item) {
64
65
        QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(item);
65
66
        if (flickable) {
113
114
{
114
115
}
115
116
 
116
 
// register item to be rebount
 
117
// register item to be rebound
117
118
bool UCListItemAttached::listenToRebind(UCListItem *item, bool listen)
118
119
{
119
 
    // we cannot bind the item until we have an other one bount
 
120
    // we cannot bind the item until we have an other one bound
120
121
    bool result = false;
121
122
    Q_D(UCListItemAttached);
122
123
    if (listen) {
123
 
        if (d->bountItem.isNull() || (d->bountItem == item)) {
124
 
            d->bountItem = item;
 
124
        if (d->boundItem.isNull() || (d->boundItem == item)) {
 
125
            d->boundItem = item;
125
126
            // rebuild flickable list
126
127
            d->buildFlickablesList();
127
128
            result = true;
128
129
        }
129
 
    } else if (d->bountItem == item) {
130
 
        d->bountItem.clear();
 
130
    } else if (d->boundItem == item) {
 
131
        d->boundItem.clear();
131
132
        result = true;
132
133
    }
133
134
    return result;
145
146
    return false;
146
147
}
147
148
 
148
 
// returns true if the given ListItem is bount to listen on moving changes
149
 
bool UCListItemAttached::isBountTo(UCListItem *item)
 
149
// returns true if the given ListItem is bound to listen on moving changes
 
150
bool UCListItemAttached::isBoundTo(UCListItem *item)
150
151
{
151
152
    Q_D(UCListItemAttached);
152
 
    return d->bountItem == item;
 
153
    return d->boundItem == item;
153
154
}
154
155
 
155
156
/*
163
164
void UCListItemAttached::disableInteractive(UCListItem *item, bool disable)
164
165
{
165
166
    Q_D(UCListItemAttached);
166
 
    if ((d->globalDisabled && disable) || (!d->globalDisabled && disable)) {
 
167
    if (disable) {
167
168
        // disabling or re-disabling
168
169
        d->disablerItem = item;
169
170
        if (d->globalDisabled == disable) {
170
171
            // was already disabled, leave
171
172
            return;
172
173
        }
173
 
        d->globalDisabled = disable;
174
 
    } else if (d->globalDisabled && !disable && d->disablerItem == item) {
 
174
        d->globalDisabled = true;
 
175
    } else if (d->globalDisabled && d->disablerItem == item) {
175
176
        // the one disabled it will enable
176
 
        d->globalDisabled = disable;
 
177
        d->globalDisabled = false;
177
178
        d->disablerItem.clear();
178
179
    } else {
179
 
        // none of the above, leave
 
180
        // !disabled && (!globalDisabled || item != d->disablerItem)
180
181
        return;
181
182
    }
182
183
    if (disable) {
190
191
void UCListItemAttached::unbindItem()
191
192
{
192
193
    Q_D(UCListItemAttached);
193
 
    if (d->bountItem) {
 
194
    if (d->boundItem) {
194
195
        // depending on content item's X coordinate, we either do animated or prompt rebind
195
 
        if (d->bountItem->contentItem()->x() != 0.0) {
 
196
        if (d->boundItem->contentItem()->x() != 0.0) {
196
197
            // content is not in origin, rebind
197
 
            UCListItemPrivate::get(d->bountItem.data())->_q_rebound();
 
198
            UCListItemPrivate::get(d->boundItem.data())->_q_rebound();
198
199
        } else {
199
200
            // do some cleanup
200
 
            UCListItemPrivate::get(d->bountItem.data())->promptRebound();
 
201
            UCListItemPrivate::get(d->boundItem.data())->promptRebound();
201
202
        }
202
 
        d->bountItem.clear();
 
203
        d->boundItem.clear();
203
204
    }
204
205
    // clear binding list
205
 
    d->clearFlickableList();
 
206
    d->clearFlickablesList();
206
207
}