Qt 4.8
Public Functions | Public Variables | Static Public Variables | List of all members
QLineEditPrivate Class Reference

#include <qlineedit_p.h>

Inheritance diagram for QLineEditPrivate:
QWidgetPrivate QObjectPrivate QObjectData

Public Functions

void _q_completionHighlighted (QString)
 
void _q_cursorPositionChanged (int, int)
 
void _q_handleWindowActivate ()
 
void _q_selectionChanged ()
 
void _q_textEdited (const QString &)
 
void _q_updateNeeded (const QRect &)
 
QRect adjustedContentsRect () const
 
QRect adjustedControlRect (const QRect &) const
 
QRect cursorRect () const
 
void drag ()
 
void init (const QString &)
 
 QLineEditPrivate ()
 
bool sendMouseEventToInputContext (QMouseEvent *e)
 This function is not intended as polymorphic usage. More...
 
void setCursorVisible (bool visible)
 
bool shouldEnableInputMethod () const
 
void updatePasswordEchoEditing (bool)
 
int xToPos (int x, QTextLine::CursorPosition=QTextLine::CursorBetweenCharacters) const
 
 ~QLineEditPrivate ()
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- 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
 

Public Variables

uint alignment
 
int bottomTextMargin
 
uint clickCausedFocus: 1
 
uint contextMenuEnabled: 1
 
QLineControlcontrol
 
uint cursorVisible: 1
 
QPoint dndPos
 
QBasicTimer dndTimer
 
uint dragEnabled: 1
 
uint frame: 1
 
int hscroll
 
int leftTextMargin
 
QString placeholderText
 
int rightTextMargin
 
QPointer< QActionselectAllAction
 
int topTextMargin
 
QPoint tripleClick
 
QBasicTimer tripleClickTimer
 
int vscroll
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- 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
 

Static Public Variables

static const int horizontalMargin
 
static const int verticalMargin
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Additional Inherited Members

- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- 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)
 

Detailed Description

Definition at line 72 of file qlineedit_p.h.

Constructors and Destructors

◆ QLineEditPrivate()

QLineEditPrivate::QLineEditPrivate ( )
inline

◆ ~QLineEditPrivate()

QLineEditPrivate::~QLineEditPrivate ( )
inline

Definition at line 85 of file qlineedit_p.h.

86  {
87  }

Functions

◆ _q_completionHighlighted()

void QLineEditPrivate::_q_completionHighlighted ( QString  newText)

Definition at line 84 of file qlineedit_p.cpp.

85 {
86  Q_Q(QLineEdit);
88  q->setText(newText);
89  } else {
90  int c = control->cursor();
91  QString text = control->text();
92  q->setText(text.left(c) + newText.mid(c));
93  control->moveCursor(control->end(), false);
94  control->moveCursor(c, true);
95  }
96 }
int cursor() const
unsigned char c[8]
Definition: qnumeric_p.h:62
QString text() const
QCompleter * completer() const
The QString class provides a Unicode character string.
Definition: qstring.h:83
CompletionMode completionMode
how the completions are provided to the user
Definition: qcompleter.h:69
#define Q_Q(Class)
Definition: qglobal.h:2483
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
void moveCursor(int pos, bool mark=false)
Moves the cursor to the given position pos.
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
QLineControl * control
Definition: qlineedit_p.h:89
int end() const
#define text
Definition: qobjectdefs.h:80

◆ _q_cursorPositionChanged()

void QLineEditPrivate::_q_cursorPositionChanged ( int  from,
int  to 
)

Definition at line 118 of file qlineedit_p.cpp.

Referenced by init().

119 {
120  Q_Q(QLineEdit);
121  q->update();
122  emit q->cursorPositionChanged(from, to);
123 }
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66

◆ _q_handleWindowActivate()

void QLineEditPrivate::_q_handleWindowActivate ( )

Definition at line 100 of file qlineedit_p.cpp.

101 {
102  Q_Q(QLineEdit);
103  if (!q->hasFocus() && control->hasSelectedText())
104  control->deselect();
105 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
QLineControl * control
Definition: qlineedit_p.h:89
bool hasSelectedText() const

◆ _q_selectionChanged()

void QLineEditPrivate::_q_selectionChanged ( )

Definition at line 133 of file qlineedit_p.cpp.

Referenced by init().

134 {
135  Q_Q(QLineEdit);
136  if (control->preeditAreaText().isEmpty()) {
138  q->initStyleOption(&opt);
139  bool showCursor = control->hasSelectedText() ?
140  q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q):
141  q->hasFocus();
142  setCursorVisible(showCursor);
143  }
144 
145  emit q->selectionChanged();
146 #ifndef QT_NO_ACCESSIBILITY
148 #endif
149 }
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
QString preeditAreaText() const
#define Q_Q(Class)
Definition: qglobal.h:2483
void setCursorVisible(bool visible)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define emit
Definition: qobjectdefs.h:76
The QStyleOptionFrameV2 class is used to describe the parameters necessary for drawing a frame in Qt ...
Definition: qstyleoption.h:134
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
QLineControl * control
Definition: qlineedit_p.h:89
bool hasSelectedText() const

◆ _q_textEdited()

void QLineEditPrivate::_q_textEdited ( const QString text)

Definition at line 107 of file qlineedit_p.cpp.

Referenced by init().

108 {
109  Q_Q(QLineEdit);
110  emit q->textEdited(text);
111 #ifndef QT_NO_COMPLETER
112  if (control->completer()
114  control->complete(-1); // update the popup on cut/paste/del
115 #endif
116 }
QCompleter * completer() const
CompletionMode completionMode
how the completions are provided to the user
Definition: qcompleter.h:69
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
QLineControl * control
Definition: qlineedit_p.h:89
void complete(int key)

◆ _q_updateNeeded()

void QLineEditPrivate::_q_updateNeeded ( const QRect rect)

Definition at line 151 of file qlineedit_p.cpp.

Referenced by init().

152 {
153  q_func()->update(adjustedControlRect(rect));
154 }
QRect adjustedControlRect(const QRect &) const
Definition: qlineedit_p.cpp:62

◆ adjustedContentsRect()

QRect QLineEditPrivate::adjustedContentsRect ( ) const

Definition at line 213 of file qlineedit_p.cpp.

Referenced by adjustedControlRect(), and xToPos().

214 {
215  Q_Q(const QLineEdit);
217  q->initStyleOption(&opt);
218  QRect r = q->style()->subElementRect(QStyle::SE_LineEditContents, &opt, q);
219  r.setX(r.x() + leftTextMargin);
220  r.setY(r.y() + topTextMargin);
221  r.setRight(r.right() - rightTextMargin);
223  return r;
224 }
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
void setY(int y)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:285
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_Q(Class)
Definition: qglobal.h:2483
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
void setX(int x)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:282
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QStyleOptionFrameV2 class is used to describe the parameters necessary for drawing a frame in Qt ...
Definition: qstyleoption.h:134
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66

◆ adjustedControlRect()

QRect QLineEditPrivate::adjustedControlRect ( const QRect rect) const

Definition at line 62 of file qlineedit_p.cpp.

Referenced by _q_updateNeeded(), and cursorRect().

63 {
64  QRect widgetRect = !rect.isEmpty() ? rect : q_func()->rect();
66  int cix = cr.x() - hscroll + horizontalMargin;
67  return widgetRect.translated(QPoint(cix, vscroll));
68 }
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
QRect adjustedContentsRect() const
static const int horizontalMargin
Definition: qlineedit_p.h:120
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ cursorRect()

QRect QLineEditPrivate::cursorRect ( ) const

Definition at line 77 of file qlineedit_p.cpp.

Referenced by setCursorVisible().

78 {
80 }
QRect adjustedControlRect(const QRect &) const
Definition: qlineedit_p.cpp:62
QRect cursorRect() const
Returns the bounds of the current cursor, as defined as a between characters cursor.
QLineControl * control
Definition: qlineedit_p.h:89

◆ drag()

void QLineEditPrivate::drag ( )

Definition at line 279 of file qlineedit_p.cpp.

280 {
281  Q_Q(QLineEdit);
282  dndTimer.stop();
283  QMimeData *data = new QMimeData;
284  data->setText(control->selectedText());
285  QDrag *drag = new QDrag(q);
286  drag->setMimeData(data);
287  Qt::DropAction action = drag->start();
288  if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q)
290 }
The QDrag class provides support for MIME-based drag and drop data transfer.
Definition: qdrag.h:61
void setMimeData(QMimeData *data)
Sets the data to be sent to the given MIME data.
Definition: qdrag.cpp:142
#define Q_Q(Class)
Definition: qglobal.h:2483
QWidgetData data
Definition: qwidget_p.h:755
DropAction
Definition: qnamespace.h:1597
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
void removeSelection()
void stop()
Stops the timer.
bool isReadOnly() const
QString selectedText() const
Qt::DropAction start(Qt::DropActions supportedActions=Qt::CopyAction)
Starts the drag and drop operation and returns a value indicating the requested drop action when it i...
Definition: qdrag.cpp:317
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
void setText(const QString &text)
Sets text as the plain text (MIME type text/plain) used to represent the data.
Definition: qmimedata.cpp:377
QLineControl * control
Definition: qlineedit_p.h:89
QBasicTimer dndTimer
Definition: qlineedit_p.h:139
QWidget * target() const
Returns the target of the drag and drop operation.
Definition: qdrag.cpp:219

◆ init()

void QLineEditPrivate::init ( const QString txt)

Definition at line 156 of file qlineedit_p.cpp.

157 {
158  Q_Q(QLineEdit);
159  control = new QLineControl(txt);
160  control->setParent(q);
161  control->setFont(q->font());
162  QObject::connect(control, SIGNAL(textChanged(QString)),
163  q, SIGNAL(textChanged(QString)));
164  QObject::connect(control, SIGNAL(textEdited(QString)),
165  q, SLOT(_q_textEdited(QString)));
166  QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),
167  q, SLOT(_q_cursorPositionChanged(int,int)));
168  QObject::connect(control, SIGNAL(selectionChanged()),
169  q, SLOT(_q_selectionChanged()));
170  QObject::connect(control, SIGNAL(accepted()),
171  q, SIGNAL(returnPressed()));
172  QObject::connect(control, SIGNAL(editingFinished()),
173  q, SIGNAL(editingFinished()));
174 #ifdef QT_KEYPAD_NAVIGATION
175  QObject::connect(control, SIGNAL(editFocusChange(bool)),
176  q, SLOT(_q_editFocusChange(bool)));
177 #endif
178  QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),
179  q, SLOT(updateMicroFocus()));
180 
181  QObject::connect(control, SIGNAL(textChanged(const QString &)),
182  q, SLOT(updateMicroFocus()));
183 
184  // for now, going completely overboard with updates.
185  QObject::connect(control, SIGNAL(selectionChanged()),
186  q, SLOT(update()));
187 
188  QObject::connect(control, SIGNAL(displayTextChanged(QString)),
189  q, SLOT(update()));
190 
191  QObject::connect(control, SIGNAL(updateNeeded(QRect)),
192  q, SLOT(_q_updateNeeded(QRect)));
193 
195  q->initStyleOption(&opt);
196  control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q));
197 #ifndef QT_NO_CURSOR
198  q->setCursor(Qt::IBeamCursor);
199 #endif
200  q->setFocusPolicy(Qt::StrongFocus);
201  q->setAttribute(Qt::WA_InputMethodEnabled);
202  // Specifies that this widget can use more, but is able to survive on
203  // less, horizontal space; and is fixed vertically.
205  q->setBackgroundRole(QPalette::Base);
206  q->setAttribute(Qt::WA_KeyCompression);
207  q->setMouseTracking(true);
208  q->setAcceptDrops(true);
209 
210  q->setAttribute(Qt::WA_MacShowFocusRect);
211 }
void _q_selectionChanged()
#define SLOT(a)
Definition: qobjectdefs.h:226
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void _q_textEdited(const QString &)
void setFont(const QFont &font)
void setPasswordCharacter(const QChar &character)
void _q_updateNeeded(const QRect &)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QStyleOptionFrameV2 class is used to describe the parameters necessary for drawing a frame in Qt ...
Definition: qstyleoption.h:134
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
QLineControl * control
Definition: qlineedit_p.h:89
void _q_cursorPositionChanged(int, int)

◆ sendMouseEventToInputContext()

bool QLineEditPrivate::sendMouseEventToInputContext ( QMouseEvent e)

This function is not intended as polymorphic usage.

Just a shared code fragment that calls QInputContext::mouseHandler for this class.

Definition at line 250 of file qlineedit_p.cpp.

251 {
252 #if !defined QT_NO_IM
253  Q_Q(QLineEdit);
254  if ( control->composeMode() ) {
255  int tmp_cursor = xToPos(e->pos().x());
256  int mousePos = tmp_cursor - control->cursor();
257  if ( mousePos < 0 || mousePos > control->preeditAreaText().length() ) {
258  mousePos = -1;
259  // don't send move events outside the preedit area
260  if ( e->type() == QEvent::MouseMove )
261  return true;
262  }
263 
264  QInputContext *qic = q->inputContext();
265  if ( qic )
266  // may be causing reset() in some input methods
267  qic->mouseHandler(mousePos, e);
268  if (!control->preeditAreaText().isEmpty())
269  return true;
270  }
271 #else
272  Q_UNUSED(e);
273 #endif
274 
275  return false;
276 }
int cursor() const
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
bool composeMode() const
QString preeditAreaText() const
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
#define Q_Q(Class)
Definition: qglobal.h:2483
int xToPos(int x, QTextLine::CursorPosition=QTextLine::CursorBetweenCharacters) const
Definition: qlineedit_p.cpp:70
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
virtual void mouseHandler(int x, QMouseEvent *event)
This function can be reimplemented in a subclass to handle mouse press, release, double-click, and move events within the preedit text.
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
QLineControl * control
Definition: qlineedit_p.h:89
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ setCursorVisible()

void QLineEditPrivate::setCursorVisible ( bool  visible)

Definition at line 226 of file qlineedit_p.cpp.

Referenced by _q_selectionChanged().

227 {
228  Q_Q(QLineEdit);
229  if ((bool)cursorVisible == visible)
230  return;
231  cursorVisible = visible;
232  if (control->inputMask().isEmpty())
233  q->update(cursorRect());
234  else
235  q->update();
236 }
QRect cursorRect() const
Definition: qlineedit_p.cpp:77
#define Q_Q(Class)
Definition: qglobal.h:2483
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString inputMask() const
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
QLineControl * control
Definition: qlineedit_p.h:89

◆ shouldEnableInputMethod()

bool QLineEditPrivate::shouldEnableInputMethod ( ) const
inline

Definition at line 104 of file qlineedit_p.h.

Referenced by updatePasswordEchoEditing().

105  {
106  return !control->isReadOnly();
107  }
bool isReadOnly() const
QLineControl * control
Definition: qlineedit_p.h:89

◆ updatePasswordEchoEditing()

void QLineEditPrivate::updatePasswordEchoEditing ( bool  editing)

Definition at line 238 of file qlineedit_p.cpp.

239 {
240  Q_Q(QLineEdit);
243 }
#define Q_Q(Class)
Definition: qglobal.h:2483
bool shouldEnableInputMethod() const
Definition: qlineedit_p.h:104
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
void updatePasswordEchoEditing(bool editing)
Sets the password echo editing to editing.
QLineControl * control
Definition: qlineedit_p.h:89

◆ xToPos()

int QLineEditPrivate::xToPos ( int  x,
QTextLine::CursorPosition  betweenOrOn = QTextLine::CursorBetweenCharacters 
) const

Definition at line 70 of file qlineedit_p.cpp.

Referenced by sendMouseEventToInputContext().

71 {
73  x-= cr.x() - hscroll + horizontalMargin;
74  return control->xToPos(x, betweenOrOn);
75 }
QRect adjustedContentsRect() const
static const int horizontalMargin
Definition: qlineedit_p.h:120
int xToPos(int x, QTextLine::CursorPosition=QTextLine::CursorBetweenCharacters) const
Returns the cursor position of the given x pixel value in relation to the displayed text...
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QLineControl * control
Definition: qlineedit_p.h:89

Properties

◆ alignment

uint QLineEditPrivate::alignment

Definition at line 118 of file qlineedit_p.h.

◆ bottomTextMargin

int QLineEditPrivate::bottomTextMargin

Definition at line 146 of file qlineedit_p.h.

Referenced by adjustedContentsRect().

◆ clickCausedFocus

uint QLineEditPrivate::clickCausedFocus

Definition at line 115 of file qlineedit_p.h.

◆ contextMenuEnabled

uint QLineEditPrivate::contextMenuEnabled

Definition at line 112 of file qlineedit_p.h.

◆ control

QLineControl* QLineEditPrivate::control

◆ cursorVisible

uint QLineEditPrivate::cursorVisible

Definition at line 113 of file qlineedit_p.h.

Referenced by setCursorVisible().

◆ dndPos

QPoint QLineEditPrivate::dndPos

Definition at line 138 of file qlineedit_p.h.

◆ dndTimer

QBasicTimer QLineEditPrivate::dndTimer

Definition at line 139 of file qlineedit_p.h.

Referenced by drag().

◆ dragEnabled

uint QLineEditPrivate::dragEnabled

Definition at line 114 of file qlineedit_p.h.

◆ frame

uint QLineEditPrivate::frame

Definition at line 111 of file qlineedit_p.h.

◆ horizontalMargin

const int QLineEditPrivate::horizontalMargin
static

Definition at line 120 of file qlineedit_p.h.

Referenced by adjustedControlRect(), and xToPos().

◆ hscroll

int QLineEditPrivate::hscroll

Definition at line 116 of file qlineedit_p.h.

Referenced by adjustedControlRect(), and xToPos().

◆ leftTextMargin

int QLineEditPrivate::leftTextMargin

Definition at line 143 of file qlineedit_p.h.

Referenced by adjustedContentsRect().

◆ placeholderText

QString QLineEditPrivate::placeholderText

Definition at line 148 of file qlineedit_p.h.

◆ rightTextMargin

int QLineEditPrivate::rightTextMargin

Definition at line 145 of file qlineedit_p.h.

Referenced by adjustedContentsRect().

◆ selectAllAction

QPointer<QAction> QLineEditPrivate::selectAllAction

Definition at line 92 of file qlineedit_p.h.

◆ topTextMargin

int QLineEditPrivate::topTextMargin

Definition at line 144 of file qlineedit_p.h.

Referenced by adjustedContentsRect().

◆ tripleClick

QPoint QLineEditPrivate::tripleClick

Definition at line 109 of file qlineedit_p.h.

◆ tripleClickTimer

QBasicTimer QLineEditPrivate::tripleClickTimer

Definition at line 110 of file qlineedit_p.h.

◆ verticalMargin

const int QLineEditPrivate::verticalMargin
static

Definition at line 119 of file qlineedit_p.h.

◆ vscroll

int QLineEditPrivate::vscroll

Definition at line 117 of file qlineedit_p.h.

Referenced by adjustedControlRect().


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