KWin
Loading...
Searching...
No Matches
tilemodel.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2022 Marco Martin <mart@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#pragma once
11
12#include "tiles/customtile.h"
13#include "tiles/tile.h"
14#include <kwin_export.h>
15
16#include <QAbstractItemModel>
17#include <QObject>
18#include <QRectF>
19
20#include <QJsonValue>
21
22class QTimer;
23
24namespace KWin
25{
26
27class Output;
28class CustomTile;
29class TileManager;
30
34class KWIN_EXPORT TileModel : public QAbstractItemModel
35{
36 Q_OBJECT
37
38public:
39 enum Roles {
40 TileRole = Qt::UserRole + 1
41 };
42 explicit TileModel(TileManager *parent = nullptr);
43 ~TileModel() override;
44
45 // QAbstractItemModel overrides
46 QHash<int, QByteArray> roleNames() const override;
47 QVariant data(const QModelIndex &index, int role) const override;
48 Qt::ItemFlags flags(const QModelIndex &index) const override;
49 QModelIndex index(int row, int column,
50 const QModelIndex &parent = QModelIndex()) const override;
51 QModelIndex parent(const QModelIndex &index) const override;
52 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
53 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
54
55private:
56 void beginInsertTile(CustomTile *tile, int position);
57 void endInsertTile();
58 void beginRemoveTile(CustomTile *tile);
59 void endRemoveTile();
60
61 // Not an uinique_pointer as the model is child of the manager so would cause a cyclic delete
62 TileManager *m_tileManager;
63 friend class CustomTile;
64
65 Q_DISABLE_COPY(TileModel)
66};
67
68} // namespace KWin