Eneboo - Documentación para desarrolladores
src/qt/src/widgets/qdatetimeedit.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qdatetimeedit.h   3.3.8   edited Jan 11 14:46 $
00003 **
00004 ** Definition of date and time edit classes
00005 **
00006 ** Created : 001103
00007 **
00008 ** Copyright (C) 2005-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the widgets module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition licenses may use this
00022 ** file in accordance with the Qt Commercial License Agreement provided
00023 ** with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QDATETIMEEDIT_H
00039 #define QDATETIMEEDIT_H
00040 
00041 #ifndef QT_H
00042 #include "qwidget.h"
00043 #include "qstring.h"
00044 #include "qdatetime.h"
00045 #endif // QT_H
00046 
00047 #ifndef QT_NO_DATETIMEEDIT
00048 
00049 class Q_EXPORT QDateTimeEditBase : public QWidget
00050 {
00051     Q_OBJECT
00052 public:
00053     QDateTimeEditBase( QWidget* parent=0, const char* name=0 )
00054         : QWidget( parent, name ) {}
00055     
00056     virtual bool setFocusSection( int sec ) = 0;
00057     virtual QString sectionFormattedText( int sec ) = 0;
00058     virtual void addNumber( int sec, int num ) = 0;
00059     virtual void removeLastNumber( int sec ) = 0;
00060 
00061 public slots:
00062     virtual void stepUp() = 0;
00063     virtual void stepDown() = 0;
00064 
00065 private:
00066 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
00067     QDateTimeEditBase( const QDateTimeEditBase & );
00068     QDateTimeEditBase &operator=( const QDateTimeEditBase & );
00069 #endif
00070 };
00071 
00072 class QDateEditPrivate;
00073 
00074 class Q_EXPORT QDateEdit : public QDateTimeEditBase
00075 {
00076     Q_OBJECT
00077     Q_ENUMS( Order )
00078     Q_PROPERTY( Order order READ order WRITE setOrder )
00079     Q_PROPERTY( QDate date READ date WRITE setDate )
00080     Q_PROPERTY( bool autoAdvance READ autoAdvance WRITE setAutoAdvance )
00081     Q_PROPERTY( QDate maxValue READ maxValue WRITE setMaxValue )
00082     Q_PROPERTY( QDate minValue READ minValue WRITE setMinValue )
00083 
00084 public:
00085     QDateEdit( QWidget* parent=0,  const char* name=0 );
00086     QDateEdit( const QDate& date, QWidget* parent=0,  const char* name=0 );
00087     ~QDateEdit();
00088 
00089     enum Order { DMY, MDY, YMD, YDM };
00090 
00091     QSize sizeHint() const;
00092     QSize minimumSizeHint() const;
00093 
00094 public slots:
00095     virtual void setDate( const QDate& date );
00096 
00097 public:
00098     QDate date() const;
00099     virtual void setOrder( Order order );
00100     Order order() const;
00101     virtual void setAutoAdvance( bool advance );
00102     bool autoAdvance() const;
00103 
00104     virtual void setMinValue( const QDate& d ) { setRange( d, maxValue() ); }
00105     QDate minValue() const;
00106     virtual void setMaxValue( const QDate& d ) { setRange( minValue(), d ); }
00107     QDate maxValue() const;
00108     virtual void setRange( const QDate& min, const QDate& max );
00109     QString separator() const;
00110     virtual void setSeparator( const QString& s );
00111 
00112     // Make removeFirstNumber() virtual in QDateTimeEditBase in 4.0
00113     void removeFirstNumber( int sec );
00114 
00115 signals:
00116     void valueChanged( const QDate& date );
00117 
00118 protected:
00119     bool event( QEvent *e );
00120     void timerEvent( QTimerEvent * );
00121     void resizeEvent( QResizeEvent * );
00122     void stepUp();
00123     void stepDown();
00124     QString sectionFormattedText( int sec );
00125     void addNumber( int sec, int num );
00126     
00127     void removeLastNumber( int sec );
00128     bool setFocusSection( int s );
00129 
00130     virtual void setYear( int year );
00131     virtual void setMonth( int month );
00132     virtual void setDay( int day );
00133     virtual void fix();
00134     virtual bool outOfRange( int y, int m, int d ) const;
00135 
00136 protected slots:
00137     void updateButtons();    
00138 
00139 private:
00140     void init();
00141     int sectionOffsetEnd( int sec ) const;
00142     int sectionLength( int sec ) const;
00143     QString sectionText( int sec ) const;
00144     QDateEditPrivate* d;
00145 
00146 #if defined(Q_DISABLE_COPY)
00147     QDateEdit( const QDateEdit & );
00148     QDateEdit &operator=( const QDateEdit & );
00149 #endif
00150 };
00151 
00152 class QTimeEditPrivate;
00153 
00154 class Q_EXPORT QTimeEdit : public QDateTimeEditBase
00155 {
00156     Q_OBJECT
00157     Q_SETS( Display )
00158     Q_PROPERTY( QTime time READ time WRITE setTime )
00159     Q_PROPERTY( bool autoAdvance READ autoAdvance WRITE setAutoAdvance )
00160     Q_PROPERTY( QTime maxValue READ maxValue WRITE setMaxValue )
00161     Q_PROPERTY( QTime minValue READ minValue WRITE setMinValue )
00162     Q_PROPERTY( Display display READ display WRITE setDisplay )
00163 
00164 public:
00165     enum Display {
00166         Hours   = 0x01,
00167         Minutes = 0x02,
00168         Seconds = 0x04,
00169         /*Reserved = 0x08,*/
00170         AMPM    = 0x10
00171     };
00172 
00173     QTimeEdit( QWidget* parent=0,  const char* name=0 );
00174     QTimeEdit( const QTime& time, QWidget* parent=0,  const char* name=0 );
00175     ~QTimeEdit();
00176 
00177     QSize sizeHint() const;
00178     QSize minimumSizeHint() const;
00179 
00180 public slots:
00181     virtual void setTime( const QTime& time );
00182 
00183 public:
00184     QTime time() const;
00185     virtual void setAutoAdvance( bool advance );
00186     bool autoAdvance() const;
00187 
00188     virtual void setMinValue( const QTime& d ) { setRange( d, maxValue() ); }
00189     QTime minValue() const;
00190     virtual void setMaxValue( const QTime& d ) { setRange( minValue(), d ); }
00191     QTime maxValue() const;
00192     virtual void setRange( const QTime& min, const QTime& max );
00193     QString separator() const;
00194     virtual void setSeparator( const QString& s );
00195 
00196     uint display() const;
00197     void setDisplay( uint disp );
00198 
00199     // Make removeFirstNumber() virtual in QDateTimeEditBase in 4.0
00200     void removeFirstNumber( int sec );
00201 
00202 signals:
00203     void valueChanged( const QTime& time );
00204 
00205 protected:
00206     bool event( QEvent *e );
00207     void timerEvent( QTimerEvent *e );
00208     void resizeEvent( QResizeEvent * );
00209     void stepUp();
00210     void stepDown();
00211     QString sectionFormattedText( int sec );
00212     void addNumber( int sec, int num );
00213     void removeLastNumber( int sec );
00214     bool setFocusSection( int s );
00215     
00216     virtual bool outOfRange( int h, int m, int s ) const;
00217     virtual void setHour( int h );
00218     virtual void setMinute( int m );
00219     virtual void setSecond( int s );
00220     
00221 protected slots:
00222     void updateButtons();
00223 
00224 private:
00225     void init();
00226     QString sectionText( int sec );
00227     QTimeEditPrivate* d;
00228 
00229 #if defined(Q_DISABLE_COPY)
00230     QTimeEdit( const QTimeEdit & );
00231     QTimeEdit &operator=( const QTimeEdit & );
00232 #endif
00233 };
00234 
00235 
00236 class QDateTimeEditPrivate;
00237 
00238 class Q_EXPORT QDateTimeEdit : public QWidget
00239 {
00240     Q_OBJECT
00241     Q_PROPERTY( QDateTime dateTime READ dateTime WRITE setDateTime )
00242 
00243 public:
00244     QDateTimeEdit( QWidget* parent=0, const char* name=0 );
00245     QDateTimeEdit( const QDateTime& datetime, QWidget* parent=0,
00246                    const char* name=0 );
00247     ~QDateTimeEdit();
00248 
00249     QSize sizeHint() const;
00250     QSize minimumSizeHint() const;
00251 
00252 public slots:
00253     virtual void setDateTime( const QDateTime & dt );
00254 
00255 public:
00256     QDateTime dateTime() const;
00257 
00258     QDateEdit* dateEdit() { return de; }
00259     QTimeEdit* timeEdit() { return te; }
00260 
00261     virtual void setAutoAdvance( bool advance );
00262     bool autoAdvance() const;
00263 
00264 signals:
00265     void valueChanged( const QDateTime& datetime );
00266 
00267 protected:
00268     // ### make init() private in Qt 4.0
00269     void init();
00270     void resizeEvent( QResizeEvent * );
00271 
00272 protected slots:
00273     // ### make these two functions private in Qt 4.0,
00274     //     and merge them into one with no parameter
00275     void newValue( const QDate& d );
00276     void newValue( const QTime& t );
00277 
00278 private:
00279     QDateEdit* de;
00280     QTimeEdit* te;
00281     QDateTimeEditPrivate* d;
00282 
00283 #if defined(Q_DISABLE_COPY)
00284     QDateTimeEdit( const QDateTimeEdit & );
00285     QDateTimeEdit &operator=( const QDateTimeEdit & );
00286 #endif
00287 };
00288 
00289 #endif
00290 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'