blob: 45b8ceabda22982727b67da1491b11f57d21324f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "windowlistmodel.h"
#include <QWindowCapture>
WindowListModel::WindowListModel(QObject *parent)
: QAbstractListModel(parent), windowList(QWindowCapture::capturableWindows())
{
}
int WindowListModel::rowCount(const QModelIndex &) const
{
return windowList.size();
}
QVariant WindowListModel::data(const QModelIndex &index, int role) const
{
Q_ASSERT(index.isValid());
Q_ASSERT(index.row() <= windowList.size());
if (role == Qt::DisplayRole) {
auto window = windowList.at(index.row());
return window.description();
}
return {};
}
QCapturableWindow WindowListModel::window(const QModelIndex &index) const
{
return windowList.at(index.row());
}
void WindowListModel::populate()
{
beginResetModel();
windowList = QWindowCapture::capturableWindows();
endResetModel();
}
#include "moc_windowlistmodel.cpp"
|