Qt 4.8
Signals | Public Functions | Private Functions | Properties | List of all members
QCalendarTextNavigator Class Reference

#include <qcalendartextnavigator_p.h>

Inheritance diagram for QCalendarTextNavigator:
QObject

Signals

void dateChanged (const QDate &date)
 
void editingFinished ()
 
- 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

QDate date () const
 
int dateEditAcceptDelay () const
 
bool eventFilter (QObject *o, QEvent *e)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
 QCalendarTextNavigator (QObject *parent=0)
 
void setDate (const QDate &date)
 
void setDateEditAcceptDelay (int delay)
 
void setWidget (QWidget *widget)
 
void timerEvent (QTimerEvent *e)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
QWidgetwidget () 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 QObjectListchildren () 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< QByteArraydynamicPropertyNames () 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...
 
template<typename 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 QMetaObjectmetaObject () 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
 
QObjectparent () 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...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Functions

void applyDate ()
 
void createDateLabel ()
 
void removeDateLabel ()
 
void updateDateLabel ()
 

Properties

QBasicTimer m_acceptTimer
 
QDate m_date
 
QFramem_dateFrame
 
QLabelm_dateText
 
QCalendarDateValidatorm_dateValidator
 
int m_editDelay
 
QWidgetm_widget
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- 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)
 
- 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...
 
QObjectsender () 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
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 68 of file qcalendartextnavigator_p.h.

Constructors and Destructors

◆ QCalendarTextNavigator()

QCalendarTextNavigator::QCalendarTextNavigator ( QObject parent = 0)
inline

Definition at line 72 of file qcalendartextnavigator_p.h.

static QDate currentDate()
Returns the current date, as reported by the system clock.
Definition: qdatetime.cpp:3115
QCalendarDateValidator * m_dateValidator
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

Functions

◆ applyDate()

void QCalendarTextNavigator::applyDate ( )
private

Definition at line 717 of file qcalendarwidget.cpp.

Referenced by QCalendarTextNavigator().

718 {
720  if (m_date == date)
721  return;
722 
723  m_date = date;
724  emit dateChanged(date);
725 }
void dateChanged(const QDate &date)
The QDate class provides date functions.
Definition: qdatetime.h:55
#define emit
Definition: qobjectdefs.h:76
QCalendarDateValidator * m_dateValidator

◆ createDateLabel()

void QCalendarTextNavigator::createDateLabel ( )
private

Definition at line 727 of file qcalendarwidget.cpp.

Referenced by QCalendarTextNavigator().

728 {
729  if (m_dateFrame)
730  return;
731  m_dateFrame = new QFrame(m_widget);
732  QVBoxLayout *vl = new QVBoxLayout;
733  m_dateText = new QLabel;
734  vl->addWidget(m_dateText);
735  m_dateFrame->setLayout(vl);
742 
745 }
void setLayout(QLayout *)
Sets the layout manager for this widget to layout.
Definition: qwidget.cpp:10104
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
void setBackgroundRole(QPalette::ColorRole)
Sets the background role of the widget to role.
Definition: qwidget.cpp:4708
QCalendarDateValidator * m_dateValidator
void setFrameShape(Shape)
Definition: qframe.cpp:284
void setFrameShadow(Shadow)
Definition: qframe.cpp:306
void setInitialDate(const QDate &date)
void setAutoFillBackground(bool enabled)
Definition: qwidget.cpp:631
void setFormat(const QString &format)
The QLabel widget provides a text or image display.
Definition: qlabel.h:55
QLocale locale
the widget&#39;s locale
Definition: qwidget.h:222
void setLocale(const QLocale &locale)
The QVBoxLayout class lines up widgets vertically.
Definition: qboxlayout.h:149
QString dateFormat(FormatType format=LongFormat) const
Returns the date format used for the current locale.
Definition: qlocale.cpp:1495
The QFrame class is the base class of widgets that can have a frame.
Definition: qframe.h:55

◆ date()

QDate QCalendarTextNavigator::date ( ) const

Definition at line 684 of file qcalendarwidget.cpp.

Referenced by QCalendarTextNavigator().

685 {
686  return m_date;
687 }

◆ dateChanged

void QCalendarTextNavigator::dateChanged ( const QDate date)
signal

Referenced by QCalendarTextNavigator().

◆ dateEditAcceptDelay()

int QCalendarTextNavigator::dateEditAcceptDelay ( ) const

Definition at line 803 of file qcalendarwidget.cpp.

Referenced by QCalendarTextNavigator().

804 {
805  return m_editDelay;
806 }

◆ editingFinished

void QCalendarTextNavigator::editingFinished ( )
signal

Referenced by QCalendarTextNavigator().

◆ eventFilter()

bool QCalendarTextNavigator::eventFilter ( QObject ,
QEvent  
)
virtual

Filters events if this object has been installed as an event filter for the watched object.

In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.

Example:

class MainWindow : public QMainWindow
{
public:
MainWindow();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
private:
QTextEdit *textEdit;
};
MainWindow::MainWindow()
{
textEdit = new QTextEdit;
setCentralWidget(textEdit);
textEdit->installEventFilter(this);
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if (obj == textEdit) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
qDebug() << "Ate key press" << keyEvent->key();
return true;
} else {
return false;
}
} else {
// pass the event on to the parent class
return QMainWindow::eventFilter(obj, event);
}
}

Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.

Warning
If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash.
See also
installEventFilter()

Reimplemented from QObject.

Definition at line 760 of file qcalendarwidget.cpp.

Referenced by QCalendarTextNavigator().

761 {
762  if (m_widget) {
763  if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) {
764  QKeyEvent* ke = (QKeyEvent*)e;
765  if ((ke->text().length() > 0 && ke->text()[0].isPrint()) || m_dateFrame) {
766  if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Select) {
767  applyDate();
769  removeDateLabel();
770  } else if (ke->key() == Qt::Key_Escape) {
771  removeDateLabel();
772  } else if (e->type() == QEvent::KeyPress) {
773  createDateLabel();
775  updateDateLabel();
776  }
777  ke->accept();
778  return true;
779  }
780  // If we are navigating let the user finish his date in old locate.
781  // If we change our mind and want it to update immediately simply uncomment below
782  /*
783  } else if (e->type() == QEvent::LocaleChange) {
784  if (m_dateValidator) {
785  m_dateValidator->setLocale(m_widget->locale());
786  m_dateValidator->setFormat(m_widget->locale().dateFormat(QLocale::ShortFormat));
787  updateDateLabel();
788  }
789  */
790  }
791  }
792  return QObject::eventFilter(o,e);
793 }
The QKeyEvent class describes a key event.
Definition: qevent.h:224
void handleKeyEvent(QKeyEvent *keyEvent)
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
#define emit
Definition: qobjectdefs.h:76
QCalendarDateValidator * m_dateValidator
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
QString text() const
Returns the Unicode text that this key generated.
Definition: qevent.h:236
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309

◆ removeDateLabel()

void QCalendarTextNavigator::removeDateLabel ( )
private

Definition at line 747 of file qcalendarwidget.cpp.

Referenced by QCalendarTextNavigator().

748 {
749  if (!m_dateFrame)
750  return;
752  m_dateFrame->hide();
754  delete m_dateValidator;
755  m_dateFrame = 0;
756  m_dateText = 0;
757  m_dateValidator = 0;
758 }
QCalendarDateValidator * m_dateValidator
void hide()
Hides the widget.
Definition: qwidget.h:501
void stop()
Stops the timer.
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145

◆ setDate()

void QCalendarTextNavigator::setDate ( const QDate date)

◆ setDateEditAcceptDelay()

void QCalendarTextNavigator::setDateEditAcceptDelay ( int  delay)

Definition at line 808 of file qcalendarwidget.cpp.

Referenced by QCalendarTextNavigator().

809 {
810  m_editDelay = delay;
811 }

◆ setWidget()

void QCalendarTextNavigator::setWidget ( QWidget widget)

◆ timerEvent()

void QCalendarTextNavigator::timerEvent ( QTimerEvent event)
virtual

This event handler can be reimplemented in a subclass to receive timer events for the object.

QTimer provides a higher-level interface to the timer functionality, and also more general information about timers. The timer event is passed in the event parameter.

See also
startTimer(), killTimer(), event()

Reimplemented from QObject.

Definition at line 795 of file qcalendarwidget.cpp.

Referenced by QCalendarTextNavigator().

796 {
797  if (e->timerId() == m_acceptTimer.timerId()) {
798  applyDate();
799  removeDateLabel();
800  }
801 }
int timerId() const
Returns the timer&#39;s ID.
Definition: qbasictimer.h:63

◆ updateDateLabel()

void QCalendarTextNavigator::updateDateLabel ( )
private

Definition at line 694 of file qcalendarwidget.cpp.

Referenced by QCalendarTextNavigator().

695 {
696  if (!m_widget)
697  return;
698 
700 
702 
703  QSize s = m_dateFrame->sizeHint();
704  QRect r = m_widget->geometry(); // later, just the table section
705  QRect newRect((r.width() - s.width()) / 2, (r.height() - s.height()) / 2, s.width(), s.height());
706  m_dateFrame->setGeometry(newRect);
707  // need to set palette after geometry update as phonestyle sets transparency
708  // effect in move event.
712 
713  m_dateFrame->raise();
714  m_dateFrame->show();
715 }
QPalette palette
the widget&#39;s palette
Definition: qwidget.h:180
void setText(const QString &)
Definition: qlabel.cpp:366
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 width() const
Returns the width.
Definition: qsize.h:126
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...
Definition: qpalette.h:206
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
QString currentText() const
const QPalette & palette() const
QCalendarDateValidator * m_dateValidator
void show()
Shows the widget and its child widgets.
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
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
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QSize sizeHint() const
em>Reimplemented Function
Definition: qframe.cpp:508
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
void setPalette(const QPalette &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4858
void start(int msec, QObject *obj)
Starts (or restarts) the timer with a msec milliseconds timeout.
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ widget()

QWidget * QCalendarTextNavigator::widget ( ) const

Definition at line 674 of file qcalendarwidget.cpp.

Referenced by QCalendarTextNavigator(), and QCalendarWidgetPrivate::setNavigatorEnabled().

675 {
676  return m_widget;
677 }

Properties

◆ m_acceptTimer

QBasicTimer QCalendarTextNavigator::m_acceptTimer
private

Definition at line 99 of file qcalendartextnavigator_p.h.

◆ m_date

QDate QCalendarTextNavigator::m_date
private

Definition at line 104 of file qcalendartextnavigator_p.h.

◆ m_dateFrame

QFrame* QCalendarTextNavigator::m_dateFrame
private

Definition at line 98 of file qcalendartextnavigator_p.h.

◆ m_dateText

QLabel* QCalendarTextNavigator::m_dateText
private

Definition at line 97 of file qcalendartextnavigator_p.h.

◆ m_dateValidator

QCalendarDateValidator* QCalendarTextNavigator::m_dateValidator
private

Definition at line 100 of file qcalendartextnavigator_p.h.

◆ m_editDelay

int QCalendarTextNavigator::m_editDelay
private

Definition at line 102 of file qcalendartextnavigator_p.h.

◆ m_widget

QWidget* QCalendarTextNavigator::m_widget
private

Definition at line 101 of file qcalendartextnavigator_p.h.


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