- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qitemdelegate.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QITEMDELEGATE_H
    00043 #define QITEMDELEGATE_H
    00044
    00045 #include <QtGui/qabstractitemdelegate.h>
    00046 #include <QtCore/qstring.h>
    00047 #include <QtGui/qpixmap.h>
    00048 #include <QtCore/qvariant.h>
    00049
    00050 QT_BEGIN_HEADER
    00051
    00052 QT_BEGIN_NAMESPACE
    00053
    00054 QT_MODULE(Gui)
    00055
    00056 #ifndef QT_NO_ITEMVIEWS
    00057
    00058 class QItemDelegatePrivate;
    00059 class QItemEditorFactory;
    00060
    00061 class Q_GUI_EXPORT QItemDelegate : public QAbstractItemDelegate
    00062 {
    00063     Q_OBJECT
    00064     Q_PROPERTY(bool clipping READ hasClipping WRITE setClipping)
    00065
    00066 public:
    00067     explicit QItemDelegate(QObject *parent = 0);
    00068     ~QItemDelegate();
    00069
    00070     bool hasClipping() const;
    00071     void setClipping(bool clip);
    00072
    00073     // painting
    00074     void paint(QPainter *painter,
    00075                const QStyleOptionViewItem &option,
    00076                const QModelIndex &index) const;
    00077     QSize sizeHint(const QStyleOptionViewItem &option,
    00078                    const QModelIndex &index) const;
    00079
    00080     // editing
    00081     QWidget *createEditor(QWidget *parent,
    00082                           const QStyleOptionViewItem &option,
    00083                           const QModelIndex &index) const;
    00084
    00085     void setEditorData(QWidget *editor, const QModelIndex &index) const;
    00086     void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
    00087
    00088     void updateEditorGeometry(QWidget *editor,
    00089                               const QStyleOptionViewItem &option,
    00090                               const QModelIndex &index) const;
    00091
    00092     // editor factory
    00093     QItemEditorFactory *itemEditorFactory() const;
    00094     void setItemEditorFactory(QItemEditorFactory *factory);
    00095
    00096 protected:
    00097     virtual void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option,
    00098                              const QRect &rect, const QString &text) const;
    00099     virtual void drawDecoration(QPainter *painter, const QStyleOptionViewItem &option,
    00100                                 const QRect &rect, const QPixmap &pixmap) const;
    00101     virtual void drawFocus(QPainter *painter, const QStyleOptionViewItem &option,
    00102                            const QRect &rect) const;
    00103     virtual void drawCheck(QPainter *painter, const QStyleOptionViewItem &option,
    00104                            const QRect &rect, Qt::CheckState state) const;
    00105     void drawBackground(QPainter *painter, const QStyleOptionViewItem &option,
    00106                         const QModelIndex &index) const;
    00107
    00108     void doLayout(const QStyleOptionViewItem &option,
    00109                   QRect *checkRect, QRect *iconRect, QRect *textRect, bool hint) const;
    00110
    00111     QRect rect(const QStyleOptionViewItem &option, const QModelIndex &index, int role) const;
    00112
    00113     bool eventFilter(QObject *object, QEvent *event);
    00114     bool editorEvent(QEvent *event, QAbstractItemModel *model,
    00115                      const QStyleOptionViewItem &option, const QModelIndex &index);
    00116
    00117     QStyleOptionViewItem setOptions(const QModelIndex &index,
    00118                                     const QStyleOptionViewItem &option) const;
    00119
    00120     QPixmap decoration(const QStyleOptionViewItem &option, const QVariant &variant) const;
    00121     QPixmap *selected(const QPixmap &pixmap, const QPalette &palette, bool enabled) const;
    00122
    00123     QRect check(const QStyleOptionViewItem &option, const QRect &bounding,
    00124                 const QVariant &variant) const;
    00125     QRect textRectangle(QPainter *painter, const QRect &rect,
    00126                         const QFont &font, const QString &text) const;
    00127
    00128 private:
    00129     Q_DECLARE_PRIVATE(QItemDelegate)
    00130     Q_DISABLE_COPY(QItemDelegate)
    00131
    00132     Q_PRIVATE_SLOT(d_func(), void _q_commitDataAndCloseEditor(QWidget*))
    00133 };
    00134
    00135 #endif // QT_NO_ITEMVIEWS
    00136
    00137 QT_END_NAMESPACE
    00138
    00139 QT_END_HEADER
    00140
    00141 #endif // QITEMDELEGATE_H