Qt 4.8
Classes | Public Functions | Static Public Functions | Public Variables | List of all members
QItemDelegatePrivate Class Reference
Inheritance diagram for QItemDelegatePrivate:
QObjectPrivate QObjectData

Classes

struct  Icon
 

Public Functions

void _q_commitDataAndCloseEditor (QWidget *editor)
 
QSizeF doTextLayout (int lineWidth) const
 
const QItemEditorFactoryeditorFactory () const
 
QIcon::Mode iconMode (QStyle::State state) const
 
QIcon::State iconState (QStyle::State state) const
 
 QItemDelegatePrivate ()
 
QRect textLayoutBounds (const QStyleOptionViewItemV2 &options) const
 
const QWidgetwidget (const QStyleOptionViewItem &option) const
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static QString replaceNewLine (QString text)
 
static QString valueToText (const QVariant &value, const QStyleOptionViewItemV4 &option)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

bool clipPainting
 
QItemEditorFactoryf
 
QTextLayout textLayout
 
QTextOption textOption
 
struct QItemDelegatePrivate::Icon tmp
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Detailed Description

Definition at line 82 of file qitemdelegate.cpp.

Constructors and Destructors

◆ QItemDelegatePrivate()

QItemDelegatePrivate::QItemDelegatePrivate ( )
inline

Definition at line 87 of file qitemdelegate.cpp.

87 : f(0), clipPainting(true) {}
QItemEditorFactory * f

Functions

◆ _q_commitDataAndCloseEditor()

void QItemDelegatePrivate::_q_commitDataAndCloseEditor ( QWidget editor)

Definition at line 139 of file qitemdelegate.cpp.

Referenced by replaceNewLine().

140 {
142  emit q->commitData(editor);
143  emit q->closeEditor(editor, QAbstractItemDelegate::SubmitModelCache);
144 }
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
The QItemDelegate class provides display and editing facilities for data items from a model...
Definition: qitemdelegate.h:61

◆ doTextLayout()

QSizeF QItemDelegatePrivate::doTextLayout ( int  lineWidth) const

Definition at line 164 of file qitemdelegate.cpp.

165 {
166  qreal height = 0;
167  qreal widthUsed = 0;
169  while (true) {
171  if (!line.isValid())
172  break;
173  line.setLineWidth(lineWidth);
174  line.setPosition(QPointF(0, height));
175  height += line.height();
176  widthUsed = qMax(widthUsed, line.naturalTextWidth());
177  }
179  return QSizeF(widthUsed, height);
180 }
double qreal
Definition: qglobal.h:1193
void setPosition(const QPointF &pos)
Moves the line to position pos.
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QTextLine class represents a line of text inside a QTextLayout.
Definition: qtextlayout.h:197
void setLineWidth(qreal width)
Lays out the line with the given width.
bool isValid() const
Returns true if this text line is valid; otherwise returns false.
Definition: qtextlayout.h:201
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QTextLine createLine()
Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise ret...
qreal naturalTextWidth() const
Returns the width of the line that is occupied by text.
void endLayout()
Ends the layout process.
qreal height() const
Returns the line&#39;s height.
void beginLayout()
Begins the layout process.

◆ editorFactory()

const QItemEditorFactory* QItemDelegatePrivate::editorFactory ( ) const
inline

Definition at line 89 of file qitemdelegate.cpp.

90  { return f ? f : QItemEditorFactory::defaultFactory(); }
QItemEditorFactory * f
static const QItemEditorFactory * defaultFactory()
Returns the default item editor factory.

◆ iconMode()

QIcon::Mode QItemDelegatePrivate::iconMode ( QStyle::State  state) const
inline

Definition at line 92 of file qitemdelegate.cpp.

93  {
94  if (!(state & QStyle::State_Enabled)) return QIcon::Disabled;
95  if (state & QStyle::State_Selected) return QIcon::Selected;
96  return QIcon::Normal;
97  }

◆ iconState()

QIcon::State QItemDelegatePrivate::iconState ( QStyle::State  state) const
inline

Definition at line 99 of file qitemdelegate.cpp.

100  { return state & QStyle::State_Open ? QIcon::On : QIcon::Off; }

◆ replaceNewLine()

static QString QItemDelegatePrivate::replaceNewLine ( QString  text)
inlinestatic

Definition at line 102 of file qitemdelegate.cpp.

Referenced by QItemDelegate::drawDisplay(), QItemDelegate::textRectangle(), and QItemDelegate::updateEditorGeometry().

103  {
104  const QChar nl = QLatin1Char('\n');
105  for (int i = 0; i < text.count(); ++i)
106  if (text.at(i) == nl)
107  text[i] = QChar::LineSeparator;
108  return text;
109  }
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
int count() const
Definition: qstring.h:103
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
#define text
Definition: qobjectdefs.h:80

◆ textLayoutBounds()

QRect QItemDelegatePrivate::textLayoutBounds ( const QStyleOptionViewItemV2 options) const

Definition at line 146 of file qitemdelegate.cpp.

147 {
148  QRect rect = option.rect;
149  const bool wrapText = option.features & QStyleOptionViewItemV2::WrapText;
150  switch (option.decorationPosition) {
153  rect.setWidth(wrapText && rect.isValid() ? rect.width() : (QFIXED_MAX));
154  break;
157  rect.setWidth(wrapText ? option.decorationSize.width() : (QFIXED_MAX));
158  break;
159  }
160 
161  return rect;
162 }
#define QFIXED_MAX
Definition: qfixed_p.h:158
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237

◆ valueToText()

QString QItemDelegatePrivate::valueToText ( const QVariant value,
const QStyleOptionViewItemV4 option 
)
static

Definition at line 358 of file qitemdelegate.cpp.

Referenced by QItemDelegate::paint(), QItemDelegate::rect(), and replaceNewLine().

359 {
360  QString text;
361  switch (value.userType()) {
362  case QMetaType::Float:
363  text = option.locale.toString(value.toFloat(), 'g');
364  break;
365  case QVariant::Double:
366  text = option.locale.toString(value.toDouble(), 'g', DBL_DIG);
367  break;
368  case QVariant::Int:
369  case QVariant::LongLong:
370  text = option.locale.toString(value.toLongLong());
371  break;
372  case QVariant::UInt:
373  case QVariant::ULongLong:
374  text = option.locale.toString(value.toULongLong());
375  break;
376  case QVariant::Date:
377  text = option.locale.toString(value.toDate(), QLocale::ShortFormat);
378  break;
379  case QVariant::Time:
380  text = option.locale.toString(value.toTime(), QLocale::ShortFormat);
381  break;
382  case QVariant::DateTime:
383  text = option.locale.toString(value.toDateTime().date(), QLocale::ShortFormat);
384  text += QLatin1Char(' ');
385  text += option.locale.toString(value.toDateTime().time(), QLocale::ShortFormat);
386  break;
387  default:
388  text = replaceNewLine(value.toString());
389  break;
390  }
391  return text;
392 }
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition: qlocale.cpp:1295
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.
Definition: qvariant.cpp:2659
qulonglong toULongLong(bool *ok=0) const
Returns the variant as as an unsigned long long int if the variant has type() ULongLong ...
Definition: qvariant.cpp:2675
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2311
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
float toFloat(bool *ok=0) const
Returns the variant as a float if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2725
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
#define DBL_DIG
QTime time() const
Returns the time part of the datetime.
Definition: qdatetime.cpp:2368
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2330
static QString replaceNewLine(QString text)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
#define text
Definition: qobjectdefs.h:80

◆ widget()

const QWidget* QItemDelegatePrivate::widget ( const QStyleOptionViewItem option) const
inline

Definition at line 123 of file qitemdelegate.cpp.

124  {
125  if (const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3 *>(&option))
126  return v3->widget;
127 
128  return 0;
129  }
The QStyleOptionViewItemV3 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:590

Properties

◆ clipPainting

bool QItemDelegatePrivate::clipPainting

Definition at line 116 of file qitemdelegate.cpp.

◆ f

QItemEditorFactory* QItemDelegatePrivate::f

Definition at line 115 of file qitemdelegate.cpp.

Referenced by editorFactory().

◆ textLayout

QTextLayout QItemDelegatePrivate::textLayout
mutable

Definition at line 120 of file qitemdelegate.cpp.

Referenced by doTextLayout().

◆ textOption

QTextOption QItemDelegatePrivate::textOption
mutable

Definition at line 121 of file qitemdelegate.cpp.

◆ tmp

struct QItemDelegatePrivate::Icon QItemDelegatePrivate::tmp

The documentation for this class was generated from the following file: