~mterry/+junk/u8

« back to all changes in this revision

Viewing changes to tests/mocks/Unity/Application/MirSurfaceListModel.cpp

Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
    m_surfaceList.append(surface);
67
67
    connectSurface(surface);
68
68
    endInsertRows();
69
 
    Q_EMIT countChanged();
 
69
    Q_EMIT countChanged(m_surfaceList.count());
70
70
    if (m_surfaceList.count() == 1) {
71
71
        Q_EMIT firstChanged();
72
72
    }
73
73
}
74
74
 
 
75
void MirSurfaceListModel::prependSurface(MirSurface *surface)
 
76
{
 
77
    beginInsertRows(QModelIndex(), 0, 0);
 
78
    m_surfaceList.prepend(surface);
 
79
    connectSurface(surface);
 
80
    endInsertRows();
 
81
    Q_EMIT countChanged(m_surfaceList.count());
 
82
    Q_EMIT firstChanged();
 
83
}
 
84
 
75
85
void MirSurfaceListModel::connectSurface(MirSurface *surface)
76
86
{
77
 
    connect(surface, &MirSurface::raiseRequested, this, [this, surface](){ this->raise(surface); });
78
87
    connect(surface, &QObject::destroyed, this, [this, surface](){ this->removeSurface(surface); });
79
88
}
80
89
 
85
94
        beginRemoveRows(QModelIndex(), i, i);
86
95
        m_surfaceList.removeAt(i);
87
96
        endRemoveRows();
88
 
        Q_EMIT countChanged();
 
97
        Q_EMIT countChanged(m_surfaceList.count());
89
98
        if (m_surfaceList.count() == 0 || i == 0) {
90
99
            Q_EMIT firstChanged();
91
100
        }
143
152
            Mir::RestoredState,
144
153
            screenshotUrl);
145
154
 
146
 
    appendSurface(surface);
 
155
    prependSurface(surface);
147
156
 
148
157
    return surface;
149
158
}