File indexing completed on 2025-03-16 11:21:24
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2022 Marco Martin <mart@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include "tiles/customtile.h" 0013 #include "tiles/quicktile.h" 0014 #include "tiles/tile.h" 0015 #include "utils/common.h" 0016 #include <kwin_export.h> 0017 0018 #include <QAbstractItemModel> 0019 #include <QObject> 0020 #include <QRectF> 0021 0022 #include <QJsonValue> 0023 0024 class QTimer; 0025 0026 namespace KWin 0027 { 0028 0029 class Output; 0030 class CustomTile; 0031 class TileManager; 0032 0033 /** 0034 * Custom tiling zones management per output. 0035 */ 0036 class KWIN_EXPORT TileModel : public QAbstractItemModel 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 enum Roles { 0042 TileRole = Qt::UserRole + 1 0043 }; 0044 explicit TileModel(TileManager *parent = nullptr); 0045 ~TileModel() override; 0046 0047 // QAbstractItemModel overrides 0048 QHash<int, QByteArray> roleNames() const override; 0049 QVariant data(const QModelIndex &index, int role) const override; 0050 Qt::ItemFlags flags(const QModelIndex &index) const override; 0051 QModelIndex index(int row, int column, 0052 const QModelIndex &parent = QModelIndex()) const override; 0053 QModelIndex parent(const QModelIndex &index) const override; 0054 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0055 int columnCount(const QModelIndex &parent = QModelIndex()) const override; 0056 0057 private: 0058 void beginInsertTile(CustomTile *tile, int position); 0059 void endInsertTile(); 0060 void beginRemoveTile(CustomTile *tile); 0061 void endRemoveTile(); 0062 0063 // Not an uinique_pointer as the model is child of the manager so would cause a cyclic delete 0064 TileManager *m_tileManager; 0065 friend class CustomTile; 0066 0067 Q_DISABLE_COPY(TileModel) 0068 }; 0069 0070 } // namespace KWin