Qt 4.8
Public Types | Signals | Public Functions | Static Public Functions | Private Functions | Properties | List of all members
QDeclarativeKeyNavigationAttached Class Reference

#include <qdeclarativeitem_p.h>

Inheritance diagram for QDeclarativeKeyNavigationAttached:
QObject QDeclarativeItemKeyFilter

Public Types

enum  Priority { BeforeItem, AfterItem }
 

Signals

void backtabChanged ()
 
void downChanged ()
 
void leftChanged ()
 
void priorityChanged ()
 
void rightChanged ()
 
void tabChanged ()
 
void upChanged ()
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

QDeclarativeItem * backtab () const
 
QDeclarativeItem * down () const
 
QDeclarativeItem * left () const
 
Priority priority () const
 
 QDeclarativeKeyNavigationAttached (QObject *=0)
 
QDeclarativeItem * right () const
 
void setBacktab (QDeclarativeItem *)
 
void setDown (QDeclarativeItem *)
 
void setLeft (QDeclarativeItem *)
 
void setPriority (Priority)
 
void setRight (QDeclarativeItem *)
 
void setTab (QDeclarativeItem *)
 
void setUp (QDeclarativeItem *)
 
QDeclarativeItem * tab () const
 
QDeclarativeItem * up () const
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectList & children () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArray > dynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
T findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObject * metaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObject * parent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThread * thread () const
 Returns the thread in which the object lives. More...
 
QObjectUserData * userData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QDeclarativeItemKeyFilter
virtual void componentComplete ()
 
virtual void inputMethodEvent (QInputMethodEvent *event, bool post)
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
 QDeclarativeItemKeyFilter (QDeclarativeItem *=0)
 
virtual ~QDeclarativeItemKeyFilter ()
 

Static Public Functions

static QDeclarativeKeyNavigationAttached * qmlAttachedProperties (QObject *)
 
- Static Public Functions inherited from QObject
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 receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Private Functions

virtual void keyPressed (QKeyEvent *event, bool post)
 
virtual void keyReleased (QKeyEvent *event, bool post)
 
void setFocusNavigation (QDeclarativeItem *currentItem, const char *dir)
 

Properties

QDeclarativeItem * backtab
 
QDeclarativeItem * down
 
QDeclarativeItem * left
 
Priority priority
 
QDeclarativeItem * right
 
QDeclarativeItem * tab
 
QDeclarativeItem * up
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Public Variables inherited from QDeclarativeItemKeyFilter
bool m_processPost
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObject * sender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectData > d_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 388 of file qdeclarativeitem_p.h.

Enumerations

◆ Priority

Constructors and Destructors

◆ QDeclarativeKeyNavigationAttached()

QDeclarativeKeyNavigationAttached::QDeclarativeKeyNavigationAttached ( QObject *  parent = 0)

Definition at line 521 of file qdeclarativeitem.cpp.

Referenced by qmlAttachedProperties().

523  QDeclarativeItemKeyFilter(qobject_cast<QDeclarativeItem*>(parent))
524 {
525  m_processPost = true;
526 }
QDeclarativeItemKeyFilter(QDeclarativeItem *=0)
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

Functions

◆ backtab()

QDeclarativeItem* QDeclarativeKeyNavigationAttached::backtab ( ) const

Referenced by setTab().

◆ backtabChanged

void QDeclarativeKeyNavigationAttached::backtabChanged ( )
signal

Referenced by setBacktab().

◆ down()

QDeclarativeItem* QDeclarativeKeyNavigationAttached::down ( ) const

Referenced by setUp().

◆ downChanged

void QDeclarativeKeyNavigationAttached::downChanged ( )
signal

Referenced by setDown().

◆ keyPressed()

void QDeclarativeKeyNavigationAttached::keyPressed ( QKeyEvent *  event,
bool  post 
)
privatevirtual

Reimplemented from QDeclarativeItemKeyFilter.

Definition at line 656 of file qdeclarativeitem.cpp.

657 {
659  event->ignore();
660 
661  if (post != m_processPost) {
663  return;
664  }
665 
666  bool mirror = false;
667  switch(event->key()) {
668  case Qt::Key_Left: {
669  if (QDeclarativeItem *parentItem = qobject_cast<QDeclarativeItem*>(parent()))
671  QDeclarativeItem* leftItem = mirror ? d->right : d->left;
672  if (leftItem) {
673  setFocusNavigation(leftItem, mirror ? "right" : "left");
674  event->accept();
675  }
676  break;
677  }
678  case Qt::Key_Right: {
679  if (QDeclarativeItem *parentItem = qobject_cast<QDeclarativeItem*>(parent()))
681  QDeclarativeItem* rightItem = mirror ? d->left : d->right;
682  if (rightItem) {
683  setFocusNavigation(rightItem, mirror ? "left" : "right");
684  event->accept();
685  }
686  break;
687  }
688  case Qt::Key_Up:
689  if (d->up) {
690  setFocusNavigation(d->up, "up");
691  event->accept();
692  }
693  break;
694  case Qt::Key_Down:
695  if (d->down) {
696  setFocusNavigation(d->down, "down");
697  event->accept();
698  }
699  break;
700  case Qt::Key_Tab:
701  if (d->tab) {
702  setFocusNavigation(d->tab, "tab");
703  event->accept();
704  }
705  break;
706  case Qt::Key_Backtab:
707  if (d->backtab) {
708  setFocusNavigation(d->backtab, "backtab");
709  event->accept();
710  }
711  break;
712  default:
713  break;
714  }
715 
716  if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event, post);
717 }
double d
Definition: qnumeric_p.h:62
virtual void keyPressed(QKeyEvent *event, bool post)
void setFocusNavigation(QDeclarativeItem *currentItem, const char *dir)
#define Q_D(Class)
Definition: qglobal.h:2482
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
bool isAccepted() const
Definition: qcoreevent.h:307
The QDeclarativeItem class provides the most basic of all visual items in QML.
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273

◆ keyReleased()

void QDeclarativeKeyNavigationAttached::keyReleased ( QKeyEvent *  event,
bool  post 
)
privatevirtual

Reimplemented from QDeclarativeItemKeyFilter.

Definition at line 719 of file qdeclarativeitem.cpp.

720 {
722  event->ignore();
723 
724  if (post != m_processPost) {
726  return;
727  }
728 
729  bool mirror = false;
730  switch(event->key()) {
731  case Qt::Key_Left:
732  if (QDeclarativeItem *parentItem = qobject_cast<QDeclarativeItem*>(parent()))
734  if (mirror ? d->right : d->left)
735  event->accept();
736  break;
737  case Qt::Key_Right:
738  if (QDeclarativeItem *parentItem = qobject_cast<QDeclarativeItem*>(parent()))
740  if (mirror ? d->left : d->right)
741  event->accept();
742  break;
743  case Qt::Key_Up:
744  if (d->up) {
745  event->accept();
746  }
747  break;
748  case Qt::Key_Down:
749  if (d->down) {
750  event->accept();
751  }
752  break;
753  case Qt::Key_Tab:
754  if (d->tab) {
755  event->accept();
756  }
757  break;
758  case Qt::Key_Backtab:
759  if (d->backtab) {
760  event->accept();
761  }
762  break;
763  default:
764  break;
765  }
766 
767  if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post);
768 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
bool isAccepted() const
Definition: qcoreevent.h:307
The QDeclarativeItem class provides the most basic of all visual items in QML.
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
virtual void keyReleased(QKeyEvent *event, bool post)

◆ left()

QDeclarativeItem* QDeclarativeKeyNavigationAttached::left ( ) const

Referenced by qmlAttachedProperties().

◆ leftChanged

void QDeclarativeKeyNavigationAttached::leftChanged ( )
signal

Referenced by setLeft().

◆ priority()

Priority QDeclarativeKeyNavigationAttached::priority ( ) const

Referenced by setBacktab().

◆ priorityChanged

void QDeclarativeKeyNavigationAttached::priorityChanged ( )
signal

Referenced by setPriority().

◆ qmlAttachedProperties()

QDeclarativeKeyNavigationAttached * QDeclarativeKeyNavigationAttached::qmlAttachedProperties ( QObject *  obj)
static

Definition at line 529 of file qdeclarativeitem.cpp.

530 {
531  return new QDeclarativeKeyNavigationAttached(obj);
532 }

◆ right()

QDeclarativeItem* QDeclarativeKeyNavigationAttached::right ( ) const

Referenced by setLeft().

◆ rightChanged

void QDeclarativeKeyNavigationAttached::rightChanged ( )
signal

Referenced by setRight().

◆ setBacktab()

void QDeclarativeKeyNavigationAttached::setBacktab ( QDeclarativeItem *  i)

Definition at line 615 of file qdeclarativeitem.cpp.

616 {
618  if (d->backtab == i)
619  return;
620  d->backtab = i;
622 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76

◆ setDown()

void QDeclarativeKeyNavigationAttached::setDown ( QDeclarativeItem *  i)

Definition at line 585 of file qdeclarativeitem.cpp.

586 {
588  if (d->down == i)
589  return;
590  d->down = i;
591  emit downChanged();
592 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76

◆ setFocusNavigation()

void QDeclarativeKeyNavigationAttached::setFocusNavigation ( QDeclarativeItem *  currentItem,
const char *  dir 
)
private

Definition at line 770 of file qdeclarativeitem.cpp.

Referenced by keyPressed().

771 {
772  QDeclarativeItem *initialItem = currentItem;
773  bool isNextItem = false;
774  do {
775  isNextItem = false;
776  if (currentItem->isVisible() && currentItem->isEnabled()) {
777  currentItem->setFocus(true);
778  } else {
779  QObject *attached =
780  qmlAttachedPropertiesObject<QDeclarativeKeyNavigationAttached>(currentItem, false);
781  if (attached) {
782  QDeclarativeItem *tempItem = qvariant_cast<QDeclarativeItem*>(attached->property(dir));
783  if (tempItem) {
784  currentItem = tempItem;
785  isNextItem = true;
786  }
787  }
788  }
789  }
790  while (currentItem != initialItem && isNextItem);
791 }
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
bool isEnabled() const
Returns true if the item is enabled; otherwise, false is returned.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
The QDeclarativeItem class provides the most basic of all visual items in QML.
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807

◆ setLeft()

void QDeclarativeKeyNavigationAttached::setLeft ( QDeclarativeItem *  i)

Definition at line 540 of file qdeclarativeitem.cpp.

541 {
543  if (d->left == i)
544  return;
545  d->left = i;
546  emit leftChanged();
547 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76

◆ setPriority()

void QDeclarativeKeyNavigationAttached::setPriority ( Priority  order)

Definition at line 647 of file qdeclarativeitem.cpp.

648 {
649  bool processPost = order == AfterItem;
650  if (processPost != m_processPost) {
651  m_processPost = processPost;
653  }
654 }
#define emit
Definition: qobjectdefs.h:76

◆ setRight()

void QDeclarativeKeyNavigationAttached::setRight ( QDeclarativeItem *  i)

Definition at line 555 of file qdeclarativeitem.cpp.

556 {
558  if (d->right == i)
559  return;
560  d->right = i;
561  emit rightChanged();
562 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76

◆ setTab()

void QDeclarativeKeyNavigationAttached::setTab ( QDeclarativeItem *  i)

Definition at line 600 of file qdeclarativeitem.cpp.

601 {
603  if (d->tab == i)
604  return;
605  d->tab = i;
606  emit tabChanged();
607 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76

◆ setUp()

void QDeclarativeKeyNavigationAttached::setUp ( QDeclarativeItem *  i)

Definition at line 570 of file qdeclarativeitem.cpp.

571 {
573  if (d->up == i)
574  return;
575  d->up = i;
576  emit upChanged();
577 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76

◆ tab()

QDeclarativeItem* QDeclarativeKeyNavigationAttached::tab ( ) const

Referenced by setDown().

◆ tabChanged

void QDeclarativeKeyNavigationAttached::tabChanged ( )
signal

Referenced by setTab().

◆ up()

QDeclarativeItem* QDeclarativeKeyNavigationAttached::up ( ) const

Referenced by setRight().

◆ upChanged

void QDeclarativeKeyNavigationAttached::upChanged ( )
signal

Referenced by setUp().

Properties

◆ backtab

QDeclarativeItem * QDeclarativeKeyNavigationAttached::backtab
private

Definition at line 398 of file qdeclarativeitem_p.h.

◆ down

QDeclarativeItem * QDeclarativeKeyNavigationAttached::down
private

Definition at line 396 of file qdeclarativeitem_p.h.

◆ left

QDeclarativeItem * QDeclarativeKeyNavigationAttached::left
private

Definition at line 393 of file qdeclarativeitem_p.h.

◆ priority

QDeclarativeKeyNavigationAttached::Priority QDeclarativeKeyNavigationAttached::priority
private

Definition at line 399 of file qdeclarativeitem_p.h.

◆ right

QDeclarativeItem * QDeclarativeKeyNavigationAttached::right
private

Definition at line 394 of file qdeclarativeitem_p.h.

◆ tab

QDeclarativeItem * QDeclarativeKeyNavigationAttached::tab
private

Definition at line 397 of file qdeclarativeitem_p.h.

◆ up

QDeclarativeItem * QDeclarativeKeyNavigationAttached::up
private

Definition at line 395 of file qdeclarativeitem_p.h.


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