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

#include <qcompleter_p.h>

Inheritance diagram for QCompleterPrivate:
QObjectPrivate QObjectData

Public Functions

void _q_autoResizePopup ()
 
void _q_complete (QModelIndex, bool=false)
 
void _q_completionSelected (const QItemSelection &)
 
void _q_fileSystemModelDirectoryLoaded (const QString &path)
 
void init (QAbstractItemModel *model=0)
 
 QCompleterPrivate ()
 
void setCurrentIndex (QModelIndex, bool=true)
 
void showPopup (const QRect &)
 
 ~QCompleterPrivate ()
 
- 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

int column
 
Qt::CaseSensitivity cs
 
bool eatFocusOut
 
bool hiddenBecauseNoMatch
 
int maxVisibleItems
 
QCompleter::CompletionMode mode
 
QAbstractItemViewpopup
 
QRect popupRect
 
QString prefix
 
QCompletionModelproxy
 
int role
 
QCompleter::ModelSorting sorting
 
QPointer< QWidgetwidget
 
bool wrap
 
- 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 **)
 
- 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 qcompleter_p.h.

Constructors and Destructors

◆ QCompleterPrivate()

QCompleterPrivate::QCompleterPrivate ( )

Definition at line 787 of file qcompleter.cpp.

790  hiddenBecauseNoMatch(false)
791 {
792 }
QPointer< QWidget > widget
Definition: qcompleter_p.h:81
QAbstractItemView * popup
Definition: qcompleter_p.h:83
QCompletionModel * proxy
Definition: qcompleter_p.h:82
Qt::CaseSensitivity cs
Definition: qcompleter_p.h:87
QCompleter::ModelSorting sorting
Definition: qcompleter_p.h:91

◆ ~QCompleterPrivate()

QCompleterPrivate::~QCompleterPrivate ( )
inline

Definition at line 78 of file qcompleter_p.h.

78 { delete popup; }
QAbstractItemView * popup
Definition: qcompleter_p.h:83

Functions

◆ _q_autoResizePopup()

void QCompleterPrivate::_q_autoResizePopup ( )

Definition at line 875 of file qcompleter.cpp.

Referenced by init().

876 {
877  if (!popup || !popup->isVisible())
878  return;
880 }
bool isVisible() const
Definition: qwidget.h:1005
QAbstractItemView * popup
Definition: qcompleter_p.h:83
void showPopup(const QRect &)
Definition: qcompleter.cpp:882

◆ _q_complete()

void QCompleterPrivate::_q_complete ( QModelIndex  index,
bool  highlighted = false 
)

Definition at line 837 of file qcompleter.cpp.

Referenced by _q_completionSelected().

838 {
839  Q_Q(QCompleter);
840  QString completion;
841 
842  if (!index.isValid() || (!proxy->showAll && (index.row() >= proxy->engine->matchCount()))) {
843  completion = prefix;
844  } else {
845  if (!(index.flags() & Qt::ItemIsEnabled))
846  return;
847  QModelIndex si = proxy->mapToSource(index);
848  si = si.sibling(si.row(), column); // for clicked()
849  completion = q->pathFromIndex(si);
850 #ifndef QT_NO_DIRMODEL
851  // add a trailing separator in inline
853  if (qobject_cast<QDirModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
854  completion += QDir::separator();
855  }
856 #endif
857 #ifndef QT_NO_FILESYSTEMMODEL
858  // add a trailing separator in inline
860  if (qobject_cast<QFileSystemModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
861  completion += QDir::separator();
862  }
863 #endif
864  }
865 
866  if (highlighted) {
867  emit q->highlighted(index);
868  emit q->highlighted(completion);
869  } else {
870  emit q->activated(index);
871  emit q->activated(completion);
872  }
873 }
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
QCompleter::CompletionMode mode
Definition: qcompleter_p.h:84
The QCompleter class provides completions based on an item model.
Definition: qcompleter.h:64
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QChar separator()
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\\" under Windows...
Definition: qdir.cpp:1831
QModelIndex mapToSource(const QModelIndex &proxyIndex) const
Reimplement this function to return the model index in the source model that corresponds to the proxy...
Definition: qcompleter.cpp:221
#define Q_Q(Class)
Definition: qglobal.h:2483
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory; otherwise ret...
Definition: qfileinfo.cpp:990
QAbstractItemModel * sourceModel() const
Returns the model that contains the data that is available through the proxy model.
int row() const
Returns the row this model index refers to.
#define emit
Definition: qobjectdefs.h:76
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
Qt::ItemFlags flags() const
Returns the flags for the item referred to by the index.
The QModelIndex class is used to locate data in a data model.
QCompletionModel * proxy
Definition: qcompleter_p.h:82
QScopedPointer< QCompletionEngine > engine
Definition: qcompleter_p.h:241
int matchCount() const
Definition: qcompleter_p.h:161
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ _q_completionSelected()

void QCompleterPrivate::_q_completionSelected ( const QItemSelection selection)

Definition at line 828 of file qcompleter.cpp.

829 {
831  if (!selection.indexes().isEmpty())
832  index = selection.indexes().first();
833 
834  _q_complete(index, true);
835 }
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void _q_complete(QModelIndex, bool=false)
Definition: qcompleter.cpp:837
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
The QModelIndex class is used to locate data in a data model.
quint16 index
QModelIndexList indexes() const
Returns a list of model indexes that correspond to the selected items.

◆ _q_fileSystemModelDirectoryLoaded()

void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded ( const QString path)

Definition at line 926 of file qcompleter.cpp.

927 {
928  Q_Q(QCompleter);
929  // Slot called when QFileSystemModel has finished loading.
930  // If we hide the popup because there was no match because the model was not loaded yet,
931  // we re-start the completion when we get the results
933  && prefix.startsWith(path) && prefix != (path + QLatin1Char('/'))
934  && widget) {
935  q->complete();
936  }
937 }
QPointer< QWidget > widget
Definition: qcompleter_p.h:81
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
The QCompleter class provides completions based on an item model.
Definition: qcompleter.h:64
#define Q_Q(Class)
Definition: qglobal.h:2483
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ init()

void QCompleterPrivate::init ( QAbstractItemModel model = 0)

Definition at line 794 of file qcompleter.cpp.

Referenced by ~QCompleterPrivate().

795 {
796  Q_Q(QCompleter);
797  proxy = new QCompletionModel(this, q);
798  QObject::connect(proxy, SIGNAL(rowsAdded()), q, SLOT(_q_autoResizePopup()));
799  q->setModel(m);
800 #ifdef QT_NO_LISTVIEW
801  q->setCompletionMode(QCompleter::InlineCompletion);
802 #else
803  q->setCompletionMode(QCompleter::PopupCompletion);
804 #endif // QT_NO_LISTVIEW
805 }
#define SLOT(a)
Definition: qobjectdefs.h:226
The QCompleter class provides completions based on an item model.
Definition: qcompleter.h:64
#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
QCompletionModel * proxy
Definition: qcompleter_p.h:82
void _q_autoResizePopup()
Definition: qcompleter.cpp:875

◆ setCurrentIndex()

void QCompleterPrivate::setCurrentIndex ( QModelIndex  index,
bool  select = true 
)

Definition at line 807 of file qcompleter.cpp.

808 {
809  Q_Q(QCompleter);
810  if (!q->popup())
811  return;
812  if (!select) {
814  } else {
815  if (!index.isValid())
816  popup->selectionModel()->clear();
817  else
820  }
821  index = popup->selectionModel()->currentIndex();
822  if (!index.isValid())
823  popup->scrollToTop();
824  else
826 }
virtual void clear()
Clears the selection model.
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
The QCompleter class provides completions based on an item model.
Definition: qcompleter.h:64
#define Q_Q(Class)
Definition: qglobal.h:2483
void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Sets the model item index to be the current item, and emits currentChanged().
QItemSelectionModel * selectionModel() const
Returns the current selection model.
virtual void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible)=0
Scrolls the view if necessary to ensure that the item at index is visible.
QAbstractItemView * popup
Definition: qcompleter_p.h:83
QModelIndex currentIndex() const
Returns the model item index for the current item, or an invalid index if there is no current item...
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
void scrollToTop()
Scrolls the view to the top.

◆ showPopup()

void QCompleterPrivate::showPopup ( const QRect rect)

Definition at line 882 of file qcompleter.cpp.

Referenced by _q_autoResizePopup().

883 {
886  QPoint pos;
887  int rh, w;
888  int h = (popup->sizeHintForRow(0) * qMin(maxVisibleItems, popup->model()->rowCount()) + 3) + 3;
890  if (hsb && hsb->isVisible())
892 
893  if (rect.isValid()) {
894  rh = rect.height();
895  w = rect.width();
896  pos = widget->mapToGlobal(dir == Qt::RightToLeft ? rect.bottomRight() : rect.bottomLeft());
897  } else {
898  rh = widget->height();
899  pos = widget->mapToGlobal(QPoint(0, widget->height() - 2));
900  w = widget->width();
901  }
902 
903  if (w > screen.width())
904  w = screen.width();
905  if ((pos.x() + w) > (screen.x() + screen.width()))
906  pos.setX(screen.x() + screen.width() - w);
907  if (pos.x() < screen.x())
908  pos.setX(screen.x());
909 
910  int top = pos.y() - rh - screen.top() + 2;
911  int bottom = screen.bottom() - pos.y();
912  h = qMax(h, popup->minimumHeight());
913  if (h > bottom) {
914  h = qMin(qMax(top, bottom), h);
915 
916  if (top > bottom)
917  pos.setY(pos.y() - h - rh + 2);
918  }
919 
920  popup->setGeometry(pos.x(), pos.y(), w, h);
921 
922  if (!popup->isVisible())
923  popup->show();
924 }
int minimumHeight() const
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
bool isVisible() const
Definition: qwidget.h:1005
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
QPointer< QWidget > widget
Definition: qcompleter_p.h:81
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
The QScrollBar widget provides a vertical or horizontal scroll bar.
Definition: qscrollbar.h:59
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
LayoutDirection
Definition: qnamespace.h:1580
QAbstractItemView * popup
Definition: qcompleter_p.h:83
void show()
Shows the widget and its child widgets.
Qt::LayoutDirection layoutDirection
the layout direction for this widget
Definition: qwidget.h:216
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
Definition: qpoint.h:137
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
QPoint bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:297
QSize sizeHint() const
Reimplemented Function
Definition: qscrollbar.cpp:490
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
QScrollBar * horizontalScrollBar() const
Returns the horizontal scroll bar.
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
const QRect availableGeometry(int screen=-1) const
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QAbstractItemModel * model() const
Returns the model that this view is presenting.
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
Definition: qpoint.h:134
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
virtual int sizeHintForRow(int row) const
Returns the height size hint for the specified row or -1 if there is no model.

Properties

◆ column

int QCompleterPrivate::column

◆ cs

Qt::CaseSensitivity QCompleterPrivate::cs

◆ eatFocusOut

bool QCompleterPrivate::eatFocusOut

Definition at line 94 of file qcompleter_p.h.

◆ hiddenBecauseNoMatch

bool QCompleterPrivate::hiddenBecauseNoMatch

Definition at line 96 of file qcompleter_p.h.

Referenced by _q_fileSystemModelDirectoryLoaded().

◆ maxVisibleItems

int QCompleterPrivate::maxVisibleItems

Definition at line 90 of file qcompleter_p.h.

Referenced by showPopup().

◆ mode

QCompleter::CompletionMode QCompleterPrivate::mode

Definition at line 84 of file qcompleter_p.h.

Referenced by _q_complete().

◆ popup

QAbstractItemView* QCompleterPrivate::popup

Definition at line 83 of file qcompleter_p.h.

Referenced by _q_autoResizePopup(), setCurrentIndex(), showPopup(), and ~QCompleterPrivate().

◆ popupRect

QRect QCompleterPrivate::popupRect

Definition at line 95 of file qcompleter_p.h.

Referenced by _q_autoResizePopup().

◆ prefix

QString QCompleterPrivate::prefix

◆ proxy

QCompletionModel* QCompleterPrivate::proxy

◆ role

int QCompleterPrivate::role

◆ sorting

QCompleter::ModelSorting QCompleterPrivate::sorting

Definition at line 91 of file qcompleter_p.h.

Referenced by QCompletionModel::createEngine().

◆ widget

QPointer<QWidget> QCompleterPrivate::widget

Definition at line 81 of file qcompleter_p.h.

Referenced by _q_fileSystemModelDirectoryLoaded(), and showPopup().

◆ wrap

bool QCompleterPrivate::wrap

Definition at line 92 of file qcompleter_p.h.


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