44 #ifndef QT_NO_ITEMVIEWS 64 #include <private/qitemeditorfactory_p.h> 67 #include <private/qobject_p.h> 68 #include <private/qdnd_p.h> 69 #include <private/qtextengine_p.h> 70 #include <private/qlayoutengine_p.h> 102 emit q->commitData(editor);
304 for (
int i = 0; i < text.
count(); ++i) {
350 switch (value.
type()) {
361 v4->decorationSize = v4->icon.actualSize(option->
decorationSize, mode, state);
366 pixmap.
fill(qvariant_cast<QColor>(value));
367 v4->icon =
QIcon(pixmap);
373 v4->decorationSize = image.
size();
378 v4->icon =
QIcon(pixmap);
379 v4->decorationSize = pixmap.
size();
449 return qvariant_cast<QSize>(value);
473 return d->editorFactory()->createEditor(t, parent);
487 #ifdef QT_NO_PROPERTIES 500 if (n ==
"dateTime") {
503 else if (editor->
inherits(
"QDateEdit"))
509 n =
d->editorFactory()->valuePropertyName(static_cast<QVariant::Type>(v.
userType()));
531 #ifdef QT_NO_PROPERTIES 541 n =
d->editorFactory()->valuePropertyName(
566 #if !defined(QT_NO_TABLEVIEW) && !defined(QT_NO_LINEEDIT) 567 if (qobject_cast<QExpandingLineEdit*>(editor) && !qobject_cast<const QTableView*>(widget))
579 geom.
adjust(-delta, 0, 0, 0);
608 d->factory = factory;
645 switch (static_cast<QKeyEvent *>(event)->key()) {
656 #ifndef QT_NO_TEXTEDIT 657 if (qobject_cast<QTextEdit *>(editor) || qobject_cast<QPlainTextEdit *>(editor))
662 #endif // QT_NO_TEXTEDIT 663 #ifndef QT_NO_LINEEDIT 664 if (
QLineEdit *e = qobject_cast<QLineEdit*>(editor))
665 if (!e->hasAcceptableInput())
667 #endif // QT_NO_LINEEDIT 690 #ifndef QT_NO_DRAGANDDROP 721 Qt::ItemFlags flags = model->
flags(index);
764 #include "moc_qstyleditemdelegate.cpp" 766 #endif // QT_NO_ITEMVIEWS The QVariant class acts like a union for the most common Qt data types.
The QPainter class performs low-level painting on widgets and other paint devices.
The QAbstractItemDelegate class is used to display and edit data items from a model.
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
The QKeyEvent class describes a key event.
QFont font
the font used for the item
QItemEditorFactory * factory
The QFontMetrics class provides font metrics information.
The QItemEditorFactory class provides widgets for editing item data in views and delegates.
#define QT_END_NAMESPACE
This macro expands to.
Q_GUI_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
QPointer< QWidget > widget
QSize size() const
Returns the size of the pixmap.
const QChar at(int i) const
Returns the character at the given index position in the string.
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Gets data from the editor widget and stores it in the specified model at the item index...
QVariant data(int role=Qt::DisplayRole) const
Returns the data for the given role for the item referred to by the index.
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
QStyle::State state
the style flags that are used when drawing the control
The QByteArray class provides an array of bytes.
~QStyledItemDelegate()
Destroys the item delegate.
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
Updates the editor for the item specified by index according to the style option given.
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
State
This enum describes the state for which a pixmap is intended to be used.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Sets the role data for the item at index to value.
int width() const
Returns the width of the rectangle.
#define Q_ARG(type, data)
static QStyle * style()
Returns the application's style object.
The QString class provides a Unicode character string.
QFontMetrics fontMetrics
the font metrics that should be used when drawing text in the control
T * qobject_cast(QObject *object)
The QObject class is the base class of all Qt objects.
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
const QItemEditorFactory * editorFactory() const
The QStyledItemDelegate class provides display and editing facilities for data items from a model...
static const QWidget * widget(const QStyleOptionViewItem &option)
QString toString(qlonglong i) const
Returns a localized string representation of i.
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Returns the item flags for the given index.
int width() const
Returns the width.
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
Returns the widget used to edit the item specified by index for editing.
QItemEditorFactory * itemEditorFactory() const
Returns the editor factory used by the item delegate.
#define QT_BEGIN_NAMESPACE
This macro expands to.
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
The QStyleOptionViewItemV3 class is used to describe the parameters necessary for drawing a frame in ...
QStyledItemDelegate(QObject *parent=0)
Constructs an item delegate with the given parent.
bool canConvert(Type t) const
Returns true if the variant's type can be cast to the requested type, t.
virtual QString displayText(const QVariant &value, const QLocale &locale) const
This function returns the string that the delegate will use to display the Qt::DisplayRole of the mod...
Mode
This enum type describes the mode for which a pixmap is intended to be used.
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
qulonglong toULongLong(bool *ok=0) const
Returns the variant as as an unsigned long long int if the variant has type() ULongLong ...
bool showDecorationSelected
whether the decoration should be highlighted on selected items
The QImage class provides a hardware-independent image representation that allows direct access to th...
Type
This enum type defines the types of variable that a QVariant can contain.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const =0
Returns the data stored under the given role for the item referred to by the index.
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Qt::MouseButton button() const
Returns the button that caused the event.
void commitData(QWidget *editor)
This signal must be emitted when the editor widget has completed editing the data, and wants to write it back into the model.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
QSize size() const
Returns the size of the image, i.
The QAbstractItemModel class provides the abstract interface for item model classes.
The QMouseEvent class contains parameters that describe a mouse event.
static QDragManager * self()
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
QDate date() const
Returns the date part of the datetime.
QPalette palette
the palette that should be used when painting the control
The QBrush class defines the fill pattern of shapes drawn by QPainter.
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
Reimplemented Function
int userType() const
Returns the storage type of the value stored in the variant.
#define Q_DECLARE_PUBLIC(Class)
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget=0) const =0
Returns the sub-area for the given element as described in the provided style option.
void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint=NoHint)
This signal is emitted when the user has finished editing an item using the specified editor...
The QFont class specifies a font used for drawing text.
void setItemEditorFactory(QItemEditorFactory *factory)
Sets the editor factory to be used by the item delegate to be the factory specified.
Type type() const
Returns the storage type of the value stored in the variant.
QObject * parent() const
Returns a pointer to the parent object.
Qt::Alignment displayAlignment
the alignment of the display value for the item
The QModelIndex class is used to locate data in a data model.
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
QSize decorationSize
the size of the decoration for the item
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
void setEditorData(QWidget *editor, const QModelIndex &index) const
Sets the data to be displayed and edited by the editor from the data model item specified by the mode...
The QRect class defines a rectangle in the plane using integer precision.
T qvariant_cast(const QVariant &)
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Renders the delegate using the given painter and style option for the item specified by index...
The QLineEdit widget is a one-line text editor.
QVariant property(const char *name) const
Returns the value of the object's name property.
The QPixmap class is an off-screen image representation that can be used as a paint device...
virtual void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const
Initialize option with the values using the index index.
static const QItemEditorFactory * defaultFactory()
Returns the default item editor factory.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
The QSize class defines the size of a two-dimensional object using integer point precision.
QTime time() const
Returns the time part of the datetime.
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
The QStyleOptionViewItem class is used to describe the parameters used to draw an item in a view widg...
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
void _q_commitDataAndCloseEditor(QWidget *editor)
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
bool eventFilter(QObject *object, QEvent *event)
Returns true if the given editor is a valid QWidget and the given event is handled; otherwise returns...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Returns the size needed by the delegate to display the item specified by index, taking into account t...
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
qreal toReal(bool *ok=0) const
Returns the variant as a qreal if the variant has type() Double , QMetaType::Float ...
QStyledItemDelegatePrivate()
The QIcon class provides scalable icons in different modes and states.