File indexing completed on 2024-04-21 04:41:46

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_DELEGATECHOOSER_H
0019 #define KQUICKITEMVIEWS_DELEGATECHOOSER_H
0020 
0021 // Qt
0022 #include <QQmlListProperty>
0023 #include <QtCore/QObject>
0024 
0025 // KQuickItemViews
0026 #include <delegatechoice.h>
0027 
0028 class DelegateChooserPrivate;
0029 
0030 class Q_DECL_EXPORT DelegateChooser : public QObject
0031 {
0032     Q_OBJECT
0033     Q_CLASSINFO("DefaultProperty", "choices")
0034 public:
0035 
0036     enum class Modes {
0037         Undefined,
0038         Columns,
0039         Rows,
0040         Indices,
0041         Expression,
0042     };
0043     Q_ENUM(Modes)
0044 
0045     Q_PROPERTY(Modes mode READ mode NOTIFY changed)
0046 
0047     Q_PROPERTY(QQmlListProperty<DelegateChoice> choices READ choices NOTIFY changed)
0048     Q_PROPERTY(QString role READ role WRITE setRole NOTIFY changed)
0049 
0050     QString role() const;
0051     void setRole(const QString &role);
0052 
0053     QQmlListProperty<DelegateChoice> choices();
0054 
0055     Modes mode() const;
0056     void setMode(Modes m);
0057 
0058 protected:
0059     virtual bool evaluateIndex(const QModelIndex& idx);
0060     virtual bool evaluateRow(int row, const QModelIndex& parent);
0061     virtual bool evaluateColumn(int row, const QModelIndex& parent);
0062 
0063 Q_SIGNALS:
0064     void changed();
0065 
0066 private:
0067     DelegateChooserPrivate *d_ptr;
0068     Q_DECLARE_PRIVATE(DelegateChooser)
0069 };
0070 
0071 #endif