File indexing completed on 2024-09-29 06:39:20
0001 /*************************************************************************** 0002 KsirkChatItem.h - 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 #ifndef KSIRKCHATITEM_H 0024 #define KSIRKCHATITEM_H 0025 0026 #include <QWidget> 0027 #include <QListWidgetItem> 0028 #include <QPushButton> 0029 #include <QColor> 0030 #include <QPixmap> 0031 0032 #define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API 0033 #include <libkdegamesprivate/kchatbasemodel.h> 0034 0035 /** 0036 * This is the class of the items displayed in the chat dialog at the bottom 0037 * of the KsirK window. This is a special listbox item able to display several 0038 * strings and pixmaps and build using stream-like operators 0039 */ 0040 class KsirkChatItem : public KChatBaseMessage 0041 { 0042 // Q_OBJECT 0043 0044 public: 0045 /** The kind of elements displayable. */ 0046 enum ElemType {Text,Pixmap,BaseMessage}; 0047 0048 /** 0049 * Default constructor 0050 */ 0051 KsirkChatItem (); 0052 0053 /** 0054 */ 0055 KsirkChatItem (const QString& name, const QString& message); 0056 0057 /** 0058 * Default destructor 0059 */ 0060 ~KsirkChatItem() override {} 0061 0062 KsirkChatItem(const KsirkChatItem& item); 0063 0064 //@{ 0065 /** Stream-like operators to add text and pixmap elements */ 0066 KsirkChatItem& operator<<(const QString& text); 0067 KsirkChatItem& operator<<(const QPixmap& pixmap); 0068 //@} 0069 0070 /** Reimplementation to paint text and pixmap items from left to right in the 0071 * correct order */ 0072 virtual void paint(QPainter* p, const QStyleOptionViewItem &option, int row); 0073 0074 QSize sizeHint(const QStyleOptionViewItem &option); 0075 0076 private: 0077 QList<QPixmap> m_pixmaps; 0078 QList<QString> m_strings; 0079 QList<ElemType> m_order; 0080 } ; // class KsirkChatItem 0081 Q_DECLARE_METATYPE(KsirkChatItem) 0082 0083 #endif // KSIRKCHATITEM_H