File indexing completed on 2024-05-05 05:40:57
0001 /************************************************************************* 0002 * Copyright (C) 2011 by Joseph Boudou * 0003 * * 0004 * https://rolisteam.org/ * 0005 * * 0006 * Rolisteam is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published * 0008 * by the Free Software Foundation; either version 2 of the License, * 0009 * or (at your option) any later version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, * 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0014 * GNU General Public License for more details. * 0015 * * 0016 * You should have received a copy of the GNU General Public License * 0017 * along with this program; if not, write to the * 0018 * Free Software Foundation, Inc., * 0019 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0020 *************************************************************************/ 0021 0022 #include "delegate.h" 0023 0024 Delegate::Delegate(QObject* parent) : QItemDelegate(parent) {} 0025 0026 Delegate::~Delegate() {} 0027 0028 int Delegate::roleAt(const QStyleOptionViewItem& option, const QModelIndex& index, QPoint pos) const 0029 { 0030 QRect decorationRect= rect(option, index, Qt::DecorationRole); 0031 QRect displayRect= rect(option, index, Qt::DisplayRole); 0032 QRect checkRect= rect(option, index, Qt::CheckStateRole); 0033 0034 doLayout(option, &checkRect, &decorationRect, &displayRect, true); 0035 0036 if(decorationRect.contains(pos)) 0037 return Qt::DecorationRole; 0038 if(displayRect.contains(pos)) 0039 return Qt::DisplayRole; 0040 if(checkRect.contains(pos)) 0041 return Qt::CheckStateRole; 0042 0043 return -1; 0044 }