Vidalia 0.2.10
|
00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file StatusEventItemDelegate.h 00013 ** \version $Id: StatusEventItemDelegate.h 4074 2009-08-28 05:36:43Z edmanm $ 00014 ** \brief Handles custom painting of items in a StatusEventWidget 00015 */ 00016 00017 #ifndef _STATUSEVENTITEMDELEGATE_H 00018 #define _STATUSEVENTITEMDELEGATE_H 00019 00020 #include <QItemDelegate> 00021 #include <QPixmap> 00022 00023 class QStringList; 00024 00025 class StatusEventItemDelegate : public QItemDelegate 00026 { 00027 Q_OBJECT 00028 00029 public: 00030 /** Default constructor. 00031 */ 00032 StatusEventItemDelegate(QObject *parent = 0); 00033 00034 /** Paints a status event item for <b>index</b> using the given paint 00035 * device <b>painter</b> and current style <b>option</b>s. 00036 */ 00037 virtual void paint(QPainter *painter, 00038 const QStyleOptionViewItem &option, 00039 const QModelIndex &index) const; 00040 00041 /** Returns a QSize representing the desired dimensions needed to paint 00042 * a status event item for <b>index</b> using the specified style 00043 * <b>option</b>s. 00044 */ 00045 virtual QSize sizeHint(const QStyleOptionViewItem &option, 00046 const QModelIndex &index) const; 00047 00048 protected: 00049 /** Splits <b>text</b> at <b>maxLineWidth</b> pixels computed using the 00050 * font dimensions given by <b>fontMetrics</b> and returns a QStringList 00051 * containing at most <b>maxLines</b> of text. If the number of wrapped 00052 * lines is greater than or equal to <b>maxLines</b>, the last line of 00053 * text will be elided. If <b>maxLines</b> is less than or equal to 0, no 00054 * eliding will be done. If <b>textHeight</b> is not NULL, it will be set 00055 * to the height (in pixels) required to display the returned wrapped 00056 * lines. 00057 */ 00058 static QStringList layoutText(const QString &text, 00059 const QFont &fontMetrics, 00060 int maxLineWidth, 00061 int maxLines = -1, 00062 int *textHeight = 0); 00063 00064 private: 00065 /** Small icon image drawn in the upper-right (or upper-left in RTL 00066 * layouts) for status events that have associated help URLs. */ 00067 QPixmap _helpIcon; 00068 }; 00069 00070 #endif 00071