File indexing completed on 2024-04-28 04:41:51

0001 /***************************************************************************
0002  *   Copyright (C) 2018 by Emmanuel Lepage Vallee                          *
0003  *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@kde.org>             *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 3 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
0017  **************************************************************************/
0018 #ifndef KQUICKITEMVIEWS_ROLE_H
0019 #define KQUICKITEMVIEWS_ROLE_H
0020 
0021 #include <adapters/geometryadapter.h>
0022 
0023 class Viewport;
0024 class RoleStrategiesPrivate;
0025 
0026 namespace GeometryStrategies
0027 {
0028 
0029 /**
0030  * A GeometryAdapter to use size hints provided by the model as a role.
0031  */
0032 class Q_DECL_EXPORT Role : public GeometryAdapter
0033 {
0034     Q_OBJECT
0035 public:
0036     explicit Role(Viewport *parent = nullptr);
0037     virtual ~Role();
0038 
0039     Q_PROPERTY(int sizeRole READ sizeRole WRITE setSizeRole NOTIFY roleChanged)
0040     Q_PROPERTY(int positionRole READ positionRole WRITE setPositionRole NOTIFY roleChanged)
0041     Q_PROPERTY(QString sizeRoleName READ sizeRoleName WRITE setSizeRoleName NOTIFY roleChanged)
0042     Q_PROPERTY(QString positionRoleName READ positionRoleName WRITE setPositionRoleName NOTIFY roleChanged)
0043 
0044     int sizeRole() const;
0045     void setSizeRole(int role);
0046 
0047     int positionRole() const;
0048     void setPositionRole(int role);
0049 
0050     QString positionRoleName() const;
0051     void setPositionRoleName(const QString& roleName);
0052 
0053     QString sizeRoleName() const;
0054     void setSizeRoleName(const QString& roleName);
0055 
0056     Q_INVOKABLE virtual QSizeF sizeHint(const QModelIndex &index, AbstractItemAdapter *adapter) const override;
0057     Q_INVOKABLE virtual QPointF positionHint(const QModelIndex &index, AbstractItemAdapter *adapter) const override;
0058 
0059 Q_SIGNALS:
0060     void roleChanged();
0061 
0062 private:
0063     RoleStrategiesPrivate *d_ptr;
0064 };
0065 
0066 }
0067 
0068 #endif