File indexing completed on 2024-03-24 04:44:22
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 #include "delegatechoice.h" 0019 0020 // Qt 0021 #include <QtCore/QModelIndex> 0022 0023 // KQukckItemViews 0024 #include <delegatechooser.h> 0025 0026 using Modes = DelegateChooser::Modes; 0027 0028 class DelegateChoicePrivate 0029 { 0030 public: 0031 QPersistentModelIndex m_Index { }; 0032 int m_Column { -1 }; 0033 int m_Row { -1 }; 0034 int m_Depth { -1 }; 0035 QQmlScriptString m_Expr { }; 0036 QQmlComponent *m_pDelegate {nullptr}; 0037 QVariant m_RoleValue { }; 0038 }; 0039 0040 DelegateChoice::DelegateChoice(QObject *parent) : 0041 QObject(parent), d_ptr(new DelegateChoicePrivate()) 0042 {} 0043 0044 DelegateChoice::~DelegateChoice() 0045 { 0046 delete d_ptr; 0047 } 0048 0049 int DelegateChoice::column() const 0050 { 0051 return d_ptr->m_Column; 0052 } 0053 0054 void DelegateChoice::setColumn(int c) 0055 { 0056 d_ptr->m_Column = c; 0057 } 0058 0059 int DelegateChoice::row() const 0060 { 0061 return d_ptr->m_Row; 0062 } 0063 0064 void DelegateChoice::setRow(int r) 0065 { 0066 d_ptr->m_Row = r; 0067 } 0068 0069 int DelegateChoice::depth() const 0070 { 0071 return d_ptr->m_Depth; 0072 } 0073 0074 void DelegateChoice::setDepth(int d) 0075 { 0076 d_ptr->m_Depth = d; 0077 } 0078 0079 QVariant DelegateChoice::index() const 0080 { 0081 return d_ptr->m_Index; 0082 } 0083 0084 void DelegateChoice::setIndex(const QVariant& i) 0085 { 0086 d_ptr->m_Index = qvariant_cast<QModelIndex>(i); 0087 } 0088 0089 QQmlComponent *DelegateChoice::delegate() const 0090 { 0091 return d_ptr->m_pDelegate; 0092 } 0093 0094 void DelegateChoice::setDelegate(QQmlComponent *d) 0095 { 0096 d_ptr->m_pDelegate = d; 0097 } 0098 0099 QQmlScriptString DelegateChoice::when() const 0100 { 0101 return d_ptr->m_Expr; 0102 } 0103 0104 void DelegateChoice::setWhen(const QQmlScriptString &w) 0105 { 0106 d_ptr->m_Expr = w; 0107 } 0108 0109 QVariant DelegateChoice::roleValue() const 0110 { 0111 return d_ptr->m_RoleValue; 0112 } 0113 0114 void DelegateChoice::setRoleValue(const QVariant &v) 0115 { 0116 d_ptr->m_RoleValue = v; 0117 } 0118 0119 bool DelegateChoice::evaluateIndex(const QModelIndex& idx) 0120 { 0121 return false; 0122 } 0123 0124 bool DelegateChoice::evaluateRow(int row, const QModelIndex& parent) 0125 { 0126 return false; 0127 } 0128 0129 bool DelegateChoice::evaluateColumn(int row, const QModelIndex& parent) 0130 { 0131 return false; 0132 }