File indexing completed on 2024-10-06 06:48:48
0001 /*************************************************************************** 0002 KsirkChatItem.cpp - description 0003 ------------------- 0004 begin : Mon Sep 26 2006 0005 copyright : (C) 2006-2007 by Gaƫl de Chalendar (aka Kleag) 0006 email : kleag@free.fr 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either either version 2 0014 of the License, or (at your option) any later version.of the License, or * 0015 * (at your option) any later version. * 0016 * * 0017 * You should have received a copy of the GNU General Public License 0018 * along with this program; if not, write to the Free Software 0019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0020 * 02110-1301, USA 0021 ***************************************************************************/ 0022 0023 #include "KsirkChatDelegate.h" 0024 #include "KsirkChatItem.h" 0025 0026 #include "ksirk_debug.h" 0027 #include <QPainter> 0028 0029 KsirkChatDelegate::KsirkChatDelegate(QObject *parent) : 0030 KChatBaseItemDelegate(parent) 0031 { 0032 // qCDebug(KSIRK_LOG) << "KsirkChatDelegate::KsirkChatDelegate"; 0033 } 0034 0035 void KsirkChatDelegate::paint(QPainter *painter, 0036 const QStyleOptionViewItem &option, 0037 const QModelIndex &index) const 0038 { 0039 // qCDebug(KSIRK_LOG) << "KsirkChatDelegate::paint"; 0040 KsirkChatItem m = index.model()->data(index, Qt::DisplayRole).value<KsirkChatItem>(); 0041 if (!m.first.isEmpty()) 0042 { 0043 // qCDebug(KSIRK_LOG) << " " <<m.first << " / " << m.second ; 0044 KChatBaseItemDelegate::paint(painter, option, index, m.first, m.second); 0045 } 0046 else 0047 { 0048 m.paint(painter, option,index.row()); 0049 } 0050 } 0051 0052 QSize KsirkChatDelegate::sizeHint(const QStyleOptionViewItem & option , 0053 const QModelIndex & index ) const 0054 { 0055 // qCDebug(KSIRK_LOG) << "KsirkChatDelegate::sizeHint"; 0056 KsirkChatItem m = index.model()->data(index, Qt::DisplayRole).value<KsirkChatItem>(); 0057 if (!m.first.isEmpty()) 0058 { 0059 return KChatBaseItemDelegate::sizeHint(option, index, m.first, m.second); 0060 } 0061 QSize result = m.sizeHint(option); 0062 // qCDebug(KSIRK_LOG) << "KsirkChatDelegate::sizeHint: " << result ; 0063 return result; 0064 } 0065 0066 QSize KsirkChatDelegate::sizeHint(const QStyleOptionViewItem &option, 0067 const QModelIndex &index, const QString& sender, 0068 const QString& message) const 0069 { 0070 return KChatBaseItemDelegate::sizeHint(option,index,sender,message); 0071 } 0072 0073 #include "moc_KsirkChatDelegate.cpp"