File indexing completed on 2024-05-12 05:32:11

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/tile.h"
0014 #include <kwin_export.h>
0015 
0016 #include <QAbstractItemModel>
0017 #include <QObject>
0018 #include <QRectF>
0019 
0020 #include <QJsonValue>
0021 
0022 class QTimer;
0023 
0024 namespace KWin
0025 {
0026 
0027 class Output;
0028 class CustomTile;
0029 class TileManager;
0030 
0031 /**
0032  * Custom tiling zones management per output.
0033  */
0034 class KWIN_EXPORT TileModel : public QAbstractItemModel
0035 {
0036     Q_OBJECT
0037 
0038 public:
0039     enum Roles {
0040         TileRole = Qt::UserRole + 1
0041     };
0042     explicit TileModel(TileManager *parent = nullptr);
0043     ~TileModel() override;
0044 
0045     // QAbstractItemModel overrides
0046     QHash<int, QByteArray> roleNames() const override;
0047     QVariant data(const QModelIndex &index, int role) const override;
0048     Qt::ItemFlags flags(const QModelIndex &index) const override;
0049     QModelIndex index(int row, int column,
0050                       const QModelIndex &parent = QModelIndex()) const override;
0051     QModelIndex parent(const QModelIndex &index) const override;
0052     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0053     int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0054 
0055 private:
0056     void beginInsertTile(CustomTile *tile, int position);
0057     void endInsertTile();
0058     void beginRemoveTile(CustomTile *tile);
0059     void endRemoveTile();
0060 
0061     // Not an uinique_pointer as the model is child of the manager so would cause a cyclic delete
0062     TileManager *m_tileManager;
0063     friend class CustomTile;
0064 
0065     Q_DISABLE_COPY(TileModel)
0066 };
0067 
0068 } // namespace KWin