diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-11 04:44:41 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-11 04:44:41 +0000 |
commit | a374efce3a207b39514be3c52264091400ce297e (patch) | |
tree | 77bdf654b55826d4f59b53a5621310206bcaead1 /libkdeedu/extdate/extdatetimeedit.cpp | |
parent | f81a494f3957d5cf38c787973415597941934727 (diff) | |
download | tdeedu-a374efce3a207b39514be3c52264091400ce297e.tar.gz tdeedu-a374efce3a207b39514be3c52264091400ce297e.zip |
TQt4 port kdeedu
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1236073 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkdeedu/extdate/extdatetimeedit.cpp')
-rw-r--r-- | libkdeedu/extdate/extdatetimeedit.cpp | 447 |
1 files changed, 210 insertions, 237 deletions
diff --git a/libkdeedu/extdate/extdatetimeedit.cpp b/libkdeedu/extdate/extdatetimeedit.cpp index 203f1dbb..e5ff6087 100644 --- a/libkdeedu/extdate/extdatetimeedit.cpp +++ b/libkdeedu/extdate/extdatetimeedit.cpp @@ -25,12 +25,12 @@ #include "extdatetimeedit.h" -#ifndef QT_NO_DATETIMEEDIT +#ifndef TQT_NO_DATETIMEEDIT -//#include "../kernel/qinternal_p.h" -//#include "../kernel/qrichtext_p.h" -#include <private/qinternal_p.h> -#include <private/qrichtext_p.h> +//#include "../kernel/tqinternal_p.h" +//#include "../kernel/tqrichtext_p.h" +#include <private/tqinternal_p.h> +#include <private/tqrichtext_p.h> #include <tqrangecontrol.h> #include <tqapplication.h> #include <tqpixmap.h> @@ -38,15 +38,15 @@ #include <tqvaluelist.h> #include <tqstring.h> #include <tqstyle.h> -#include <tqdatetimeedit.h> //need for QTimeEdit +#include <tqdatetimeedit.h> //need for TQTimeEdit #define EXTDATETIMEEDIT_HIDDEN_CHAR '0' -static QString *lDateSep = 0; -static QString *lTimeSep = 0; +static TQString *lDateSep = 0; +static TQString *lTimeSep = 0; static bool lAMPM = FALSE; -static QString *lAM = 0; -static QString *lPM = 0; +static TQString *lAM = 0; +static TQString *lPM = 0; static ExtDateEdit::Order lOrder = ExtDateEdit::YMD; static int refcount = 0; @@ -74,8 +74,8 @@ static void readLocaleSettings() lDateSep = new TQString(); lTimeSep = new TQString(); -#if defined(Q_WS_WIN) - QT_WA( { +#if defined(TQ_WS_WIN) + TQT_WA( { TCHAR data[10]; GetLocaleInfo( LOCALE_USER_DEFAULT, LOCALE_SDATE, data, 10 ); *lDateSep = TQString::fromUcs2( (ushort*)data ); @@ -113,9 +113,9 @@ static void readLocaleSettings() *lTimeSep = ":"; #endif TQString d = ExtDate( 1999, 11, 22 ).toString( Qt::LocalDate ); - dpos = d.find( "22" ); - mpos = d.find( "11" ); - ypos = d.find( "99" ); + dpos = d.tqfind( "22" ); + mpos = d.tqfind( "11" ); + ypos = d.tqfind( "99" ); if ( dpos > -1 && mpos > -1 && ypos > -1 ) { // test for DMY, MDY, YMD, YDM if ( dpos < mpos && mpos < ypos ) { @@ -133,19 +133,19 @@ static void readLocaleSettings() // this code needs to change if new formats are added -#ifndef Q_WS_WIN - TQString sep = d.mid( QMIN( dpos, mpos ) + 2, QABS( dpos - mpos ) - 2 ); - if ( d.contains( sep ) == 2 ) { +#ifndef TQ_WS_WIN + TQString sep = d.mid( TQMIN( dpos, mpos ) + 2, TQABS( dpos - mpos ) - 2 ); + if ( d.tqcontains( sep ) == 2 ) { *lDateSep = sep; } #endif } -#ifndef Q_WS_WIN +#ifndef TQ_WS_WIN TQString t = TQTime( 11, 22, 33 ).toString( Qt::LocalDate ); - dpos = t.find( "11" ); - mpos = t.find( "22" ); - ypos = t.find( "33" ); + dpos = t.tqfind( "11" ); + mpos = t.tqfind( "22" ); + ypos = t.tqfind( "33" ); // We only allow hhmmss if ( dpos > -1 && dpos < mpos && mpos < ypos ) { TQString sep = t.mid( dpos + 2, mpos - dpos - 2 ); @@ -182,11 +182,11 @@ class ExtDateTimeEditorPrivate public: ExtDateTimeEditorPrivate() : frm( TRUE ), - parag( new QTextParagraph( 0, 0, 0, FALSE ) ), + parag( new TQTextParagraph( 0, 0, 0, FALSE ) ), focusSec(0) { parag->formatter()->setWrapEnabled( FALSE ); - cursor = new QTextCursor( 0 ); + cursor = new TQTextCursor( 0 ); cursor->setParagraph( parag ); offset = 0; sep = localDateSep(); @@ -200,7 +200,7 @@ public: cleanup(); } - void appendSection( const QNumberSection& sec ) + void appendSection( const TQNumberSection& sec ) { sections.append( sec ); @@ -235,7 +235,7 @@ public: } return -1; } - QNumberSection section( int idx ) const + TQNumberSection section( int idx ) const { return sections[idx]; } @@ -266,20 +266,20 @@ public: { int fw = 0; if ( frm ) - fw = style.pixelMetric(TQStyle::PM_DefaultFrameWidth); + fw = style.tqpixelMetric(TQStyle::PM_DefaultFrameWidth); parag->truncate( 0 ); parag->append( txt ); if ( !focus ) - parag->removeSelection( QTextDocument::Standard ); + parag->removeSelection( TQTextDocument::Standard ); else { applyFocusSelection(); } /* color all EXTDATETIMEEDIT_HIDDEN_CHAR chars to background color */ - QTextFormat *fb = parag->formatCollection()->format( p.font(), + TQTextFormat *fb = parag->formatCollection()->format( p.font(), cg.base() ); - QTextFormat *nf = parag->formatCollection()->format( p.font(), + TQTextFormat *nf = parag->formatCollection()->format( p.font(), cg.text() ); for ( uint i = 0; i < txt.length(); ++i ) { parag->setFormat( i, 1, nf ); @@ -295,7 +295,7 @@ public: TQRect r( rect.x(), rect.y(), rect.width() - 2 * ( 2 + fw ), rect.height() ); parag->pseudoDocument()->docRect = r; - parag->invalidate(0); + parag->tqinvalidate(0); parag->format(); int xoff = 2 + fw - offset; @@ -322,7 +322,7 @@ protected: if ( focusSec > -1 ) { int selstart = sections[ focusSec ].selectionStart(); int selend = sections[ focusSec ].selectionEnd(); - parag->setSelection( QTextDocument::Standard, selstart, selend ); + parag->setSelection( TQTextDocument::Standard, selstart, selend ); parag->format(); if ( parag->at( selstart )->x < offset || parag->at( selend )->x + parag->string()->width( selend ) > offset + sz.width() ) { @@ -332,52 +332,25 @@ protected: } private: bool frm; - QTextParagraph *parag; - QTextCursor *cursor; + TQTextParagraph *parag; + TQTextCursor *cursor; TQSize sz; int focusSec; - TQValueList< QNumberSection > sections; + TQValueList< TQNumberSection > sections; TQString sep; int offset; }; -class ExtDateTimeSpinWidget : public QSpinWidget -{ -public: - ExtDateTimeSpinWidget( TQWidget *parent, const char *name ) - : TQSpinWidget( parent, name ) - { - } - -protected: -#ifndef QT_NO_WHEELEVENT - void wheelEvent( TQWheelEvent *e ) - { - ExtDateTimeEditor *editor = (ExtDateTimeEditor*)editWidget()->qt_cast( "ExtDateTimeEditor" ); - Q_ASSERT( editor ); - if ( !editor ) - return; - - int section = editor->sectionAt( e->pos() ); - editor->setFocusSection( section ); - - if ( section == -1 ) - return; - TQSpinWidget::wheelEvent( e ); - } -#endif -}; - /*! - Constructs an empty datetime editor with parent \a parent and + Constructs an empty datetime editor with tqparent \a tqparent and called \a name. */ -ExtDateTimeEditor::ExtDateTimeEditor( ExtDateTimeEditBase * parent, +ExtDateTimeEditor::ExtDateTimeEditor( ExtDateTimeEditBase * tqparent, const char * name ) - : TQWidget( parent, name, WNoAutoErase ) + : TQWidget( tqparent, name, WNoAutoErase ) { d = new ExtDateTimeEditorPrivate(); - cw = parent; + cw = tqparent; init(); } @@ -399,7 +372,7 @@ void ExtDateTimeEditor::init() setBackgroundMode( PaletteBase ); setFocusSection( -1 ); installEventFilter( this ); - setFocusPolicy( WheelFocus ); + setFocusPolicy( TQ_WheelFocus ); } @@ -411,7 +384,7 @@ bool ExtDateTimeEditor::event( TQEvent *e ) { if ( e->type() == TQEvent::FocusIn || e->type() == TQEvent::FocusOut ) { if ( e->type() == TQEvent::FocusOut ) - qApp->sendEvent( cw, e ); + tqApp->sendEvent( cw, e ); update( rect() ); } else if ( e->type() == TQEvent::AccelOverride ) { TQKeyEvent* ke = (TQKeyEvent*) e; @@ -458,12 +431,12 @@ void ExtDateTimeEditor::paintEvent( TQPaintEvent * ) } } - QSharedDoubleBuffer buffer( this ); + TQSharedDoubleBuffer buffer( this ); const TQBrush &bg = - colorGroup().brush( isEnabled() ? TQColorGroup::Base : TQColorGroup::Background ); + tqcolorGroup().brush( isEnabled() ? TQColorGroup::Base : TQColorGroup::Background ); buffer.painter()->fillRect( 0, 0, width(), height(), bg ); - d->paint( txt, hasFocus(), *buffer.painter(), colorGroup(), rect(), - style() ); + d->paint( txt, hasFocus(), *buffer.painter(), tqcolorGroup(), rect(), + tqstyle() ); buffer.end(); } @@ -492,7 +465,7 @@ void ExtDateTimeEditor::mousePressEvent( TQMouseEvent *e ) int sec = sectionAt( p ); if ( sec != -1 ) { cw->setFocusSection( sec ); - repaint( rect(), FALSE ); + tqrepaint( rect(), FALSE ); } } @@ -501,20 +474,20 @@ void ExtDateTimeEditor::mousePressEvent( TQMouseEvent *e ) */ bool ExtDateTimeEditor::eventFilter( TQObject *o, TQEvent *e ) { - if ( o == this ) { + if ( TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(this) ) { if ( e->type() == TQEvent::KeyPress ) { TQKeyEvent *ke = (TQKeyEvent*)e; switch ( ke->key() ) { case Key_Right: if ( d->focusSection() < (int)d->sectionCount()-1 ) { if ( cw->setFocusSection( focusSection()+1 ) ) - repaint( rect(), FALSE ); + tqrepaint( rect(), FALSE ); } return TRUE; case Key_Left: if ( d->focusSection() > 0 ) { if ( cw->setFocusSection( focusSection()-1 ) ) - repaint( rect(), FALSE ); + tqrepaint( rect(), FALSE ); } return TRUE; case Key_Up: @@ -524,32 +497,32 @@ bool ExtDateTimeEditor::eventFilter( TQObject *o, TQEvent *e ) cw->stepDown(); return TRUE; case Key_Backspace: - if ( ::qt_cast<ExtDateEdit*>(cw) ) + if ( ::tqqt_cast<ExtDateEdit*>(cw) ) ((ExtDateEdit*)cw)->removeFirstNumber( d->focusSection() ); - else if ( ::qt_cast<QTimeEdit*>(cw) ) - ((QTimeEdit*)cw)->removeFirstNumber( d->focusSection() ); + else if ( ::tqqt_cast<TQTimeEdit*>(cw) ) + ((TQTimeEdit*)cw)->removeFirstNumber( d->focusSection() ); return TRUE; case Key_Delete: cw->removeLastNumber( d->focusSection() ); return TRUE; case Key_Tab: case Key_BackTab: { - if ( ke->state() == Qt::ControlButton ) + if ( ke->state() == TQt::ControlButton ) return FALSE; TQWidget *w = this; bool hadDateEdit = FALSE; while ( w ) { - if ( ::qt_cast<ExtDateTimeSpinWidget*>(w) && qstrcmp( w->name(), "qt_spin_widget" ) != 0 || - ::qt_cast<ExtDateTimeEdit*>(w) ) + if ( ::tqqt_cast<ExtDateTimeSpinWidget*>(w) && qstrcmp( w->name(), "qt_spin_widget" ) != 0 || + ::tqqt_cast<ExtDateTimeEdit*>(w) ) break; - hadDateEdit = hadDateEdit || ::qt_cast<ExtDateEdit*>(w); - w = w->parentWidget(); + hadDateEdit = hadDateEdit || ::tqqt_cast<ExtDateEdit*>(w); + w = w->tqparentWidget(); } if ( w ) { - if ( !::qt_cast<ExtDateTimeEdit*>(w) ) { - w = w->parentWidget(); + if ( !::tqqt_cast<ExtDateTimeEdit*>(w) ) { + w = w->tqparentWidget(); } else { ExtDateTimeEdit *ed = (ExtDateTimeEdit*)w; if ( hadDateEdit && ke->key() == Key_Tab ) { @@ -559,29 +532,29 @@ bool ExtDateTimeEditor::eventFilter( TQObject *o, TQEvent *e ) ed->dateEdit()->setFocus(); return TRUE; } else { - while ( w && !::qt_cast<ExtDateTimeEdit*>(w) ) - w = w->parentWidget(); + while ( w && !::tqqt_cast<ExtDateTimeEdit*>(w) ) + w = w->tqparentWidget(); } } - qApp->sendEvent( w, e ); + tqApp->sendEvent( w, e ); return TRUE; } } break; default: - TQString txt = ke->text().lower(); + TQString txt = TQString(ke->text()).lower(); if ( !txt.isEmpty() && !separator().isEmpty() && txt[0] == separator()[0] ) { // do the same thing as KEY_RIGHT when the user presses the separator key if ( d->focusSection() < 2 ) { if ( cw->setFocusSection( focusSection()+1 ) ) - repaint( rect(), FALSE ); + tqrepaint( rect(), FALSE ); } return TRUE; - } else if ( !txt.isEmpty() && ::qt_cast<QTimeEdit*>(cw) && focusSection() == (int) d->sectionCount()-1 ) { + } else if ( !txt.isEmpty() && ::tqqt_cast<TQTimeEdit*>(cw) && focusSection() == (int) d->sectionCount()-1 ) { // the first character of the AM/PM indicator toggles if the section has focus - QTimeEdit *te = (QTimeEdit*)cw; + TQTimeEdit *te = (TQTimeEdit*)cw; TQTime time = te->time(); - if ( lAMPM && lAM && lPM && (te->display()&QTimeEdit::AMPM) ) { + if ( lAMPM && lAM && lPM && (te->display()&TQTimeEdit::AMPM) ) { if ( txt[0] == (*lAM).lower()[0] && time.hour() >= 12 ) { time.setHMS( time.hour()-12, time.minute(), time.second(), time.msec() ); te->setTime( time ); @@ -608,7 +581,7 @@ bool ExtDateTimeEditor::eventFilter( TQObject *o, TQEvent *e ) Appends the number section \a sec to the editor. */ -void ExtDateTimeEditor::appendSection( const QNumberSection& sec ) +void ExtDateTimeEditor::appendSection( const TQNumberSection& sec ) { d->appendSection( sec ); } @@ -678,7 +651,7 @@ bool ExtDateTimeEditor::setFocusSection( int sec ) \internal Small abstract class that provides some functions that are common - for both ExtDateEdit and QTimeEdit. Its used internally by + for both ExtDateEdit and TQTimeEdit. Its used internally by ExtDateTimeEditor. */ @@ -767,9 +740,9 @@ public: with a date, e.g. \code - ExtDateEdit *dateEdit = new ExtDateEdit( ExtDate::currentDate(), this ); - dateEdit->setRange( ExtDate::currentDate().addDays( -365 ), - ExtDate::currentDate().addDays( 365 ) ); + ExtDateEdit *dateEdit = new ExtDateEdit( ExtDate::tqcurrentDate(), this ); + dateEdit->setRange( ExtDate::tqcurrentDate().addDays( -365 ), + ExtDate::tqcurrentDate().addDays( 365 ) ); dateEdit->setOrder( ExtDateEdit::MDY ); dateEdit->setAutoAdvance( TRUE ); \endcode @@ -793,7 +766,7 @@ public: \image html datetimewidgets.png "Date Time Widgets" - \sa ExtDate QTimeEdit ExtDateTimeEdit + \sa ExtDate TQTimeEdit ExtDateTimeEdit */ /*! @@ -806,7 +779,7 @@ public: /*! - \enum QTimeEdit::Display + \enum TQTimeEdit::Display This enum defines the sections that comprise a time @@ -819,12 +792,12 @@ public: */ /*! - Constructs an empty date editor which is a child of \a parent and + Constructs an empty date editor which is a child of \a tqparent and called name \a name. */ -ExtDateEdit::ExtDateEdit( TQWidget * parent, const char * name ) - : ExtDateTimeEditBase( parent, name ) +ExtDateEdit::ExtDateEdit( TQWidget * tqparent, const char * name ) + : ExtDateTimeEditBase( tqparent, name ) { init(); updateButtons(); @@ -833,14 +806,14 @@ ExtDateEdit::ExtDateEdit( TQWidget * parent, const char * name ) /*! \overload - Constructs a date editor with the initial value \a date, parent \a - parent and called \a name. + Constructs a date editor with the initial value \a date, tqparent \a + tqparent and called \a name. The date editor is initialized with \a date. */ -ExtDateEdit::ExtDateEdit( const ExtDate& date, TQWidget * parent, const char * name ) - : ExtDateTimeEditBase( parent, name ) +ExtDateEdit::ExtDateEdit( const ExtDate& date, TQWidget * tqparent, const char * name ) + : ExtDateTimeEditBase( tqparent, name ) { init(); setDate( date ); @@ -861,9 +834,9 @@ void ExtDateEdit::init() connect( d->controls, TQT_SIGNAL( stepDownPressed() ), TQT_SLOT( stepDown() ) ); connect( this, TQT_SIGNAL( valueChanged(const ExtDate&) ), TQT_SLOT( updateButtons() ) ); - d->ed->appendSection( QNumberSection( 0,4 ) ); - d->ed->appendSection( QNumberSection( 5,7 ) ); - d->ed->appendSection( QNumberSection( 8,10 ) ); + d->ed->appendSection( TQNumberSection( 0,4 ) ); + d->ed->appendSection( TQNumberSection( 5,7 ) ); + d->ed->appendSection( TQNumberSection( 8,10 ) ); d->yearSection = -1; d->monthSection = -1; @@ -883,7 +856,7 @@ void ExtDateEdit::init() d->max = ExtDate( 50000, 12, 31 ); d->changed = FALSE; - setSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed ); + tqsetSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed ); refcount++; } @@ -997,24 +970,24 @@ void ExtDateEdit::resizeEvent( TQResizeEvent * ) /*! \reimp */ -TQSize ExtDateEdit::sizeHint() const +TQSize ExtDateEdit::tqsizeHint() const { constPolish(); TQFontMetrics fm( font() ); - int fw = style().pixelMetric( TQStyle::PM_DefaultFrameWidth, this ); - int h = QMAX( fm.lineSpacing(), 14 ) + 2; + int fw = tqstyle().tqpixelMetric( TQStyle::PM_DefaultFrameWidth, this ); + int h = TQMAX( fm.lineSpacing(), 14 ) + 2; int w = 2 + fm.width( '9' ) * 8 + fm.width( d->ed->separator() ) * 2 + d->controls->upRect().width() + fw * 4; - return TQSize( w, QMAX(h + fw * 2,20) ).expandedTo( TQApplication::globalStrut() ); + return TQSize( w, TQMAX(h + fw * 2,20) ).expandedTo( TQApplication::globalStrut() ); } /*! \reimp */ -TQSize ExtDateEdit::minimumSizeHint() const +TQSize ExtDateEdit::tqminimumSizeHint() const { - return sizeHint(); + return tqsizeHint(); } @@ -1160,7 +1133,7 @@ void ExtDateEdit::setOrder( ExtDateEdit::Order order ) } if ( isVisible() ) - d->ed->repaint( d->ed->rect(), FALSE ); + d->ed->tqrepaint( d->ed->rect(), FALSE ); } @@ -1198,7 +1171,7 @@ void ExtDateEdit::stepUp() emit valueChanged( date() ); } - d->ed->repaint( d->ed->rect(), FALSE ); + d->ed->tqrepaint( d->ed->rect(), FALSE ); } @@ -1232,7 +1205,7 @@ void ExtDateEdit::stepDown() emit valueChanged( date() ); } - d->ed->repaint( d->ed->rect(), FALSE ); + d->ed->tqrepaint( d->ed->rect(), FALSE ); } /*! @@ -1295,7 +1268,7 @@ void ExtDateEdit::setDay( int day ) If the date property is not valid, the editor displays all zeroes and ExtDateEdit::date() will return an invalid date. It is strongly recommended that the editor is given a default date value (e.g. - currentDate()). That way, attempts to set the date property to an + tqcurrentDate()). That way, attempts to set the date property to an invalid date will fail. When changing the date property, if the date is less than @@ -1319,7 +1292,7 @@ void ExtDateEdit::setDate( const ExtDate& date ) emit valueChanged( date ); } d->changed = FALSE; - d->ed->repaint( d->ed->rect(), FALSE ); + d->ed->tqrepaint( d->ed->rect(), FALSE ); } ExtDate ExtDateEdit::date() const @@ -1341,8 +1314,8 @@ ExtDate ExtDateEdit::date() const bool ExtDateEdit::outOfRange( int y, int m, int d ) const { if ( ExtDate::isValid( y, m, d ) ) { - ExtDate currentDate( y, m, d ); - if ( currentDate > maxValue() || currentDate < minValue() ) { + ExtDate tqcurrentDate( y, m, d ); + if ( tqcurrentDate > maxValue() || tqcurrentDate < minValue() ) { //## outOfRange should set overwrite? return TRUE; } @@ -1454,8 +1427,8 @@ void ExtDateEdit::addNumber( int sec, int num ) emit valueChanged( date() ); } d->overwrite = overwrite; - d->timerId = startTimer( qApp->doubleClickInterval()*4 ); - d->ed->repaint( d->ed->rect(), FALSE ); + d->timerId = startTimer( tqApp->doubleClickInterval()*4 ); + d->ed->tqrepaint( d->ed->rect(), FALSE ); } @@ -1502,7 +1475,7 @@ void ExtDateEdit::fix() changed = TRUE; } - int currentYear = ExtDate::currentDate().year(); + int currentYear = ExtDate::tqcurrentDate().year(); int year = d->y; /* No longer valid for extended dates if ( year < 100 ) { @@ -1608,7 +1581,7 @@ void ExtDateEdit::removeFirstNumber( int sec ) d->d = txt.toInt(); d->dayCache = d->d; } - d->ed->repaint( d->ed->rect(), FALSE ); + d->ed->tqrepaint( d->ed->rect(), FALSE ); } /*! \reimp @@ -1634,7 +1607,7 @@ void ExtDateEdit::removeLastNumber( int sec ) d->d = txt.toInt(); d->dayCache = d->d; } - d->ed->repaint( d->ed->rect(), FALSE ); + d->ed->tqrepaint( d->ed->rect(), FALSE ); } /*! @@ -1675,7 +1648,7 @@ void ExtDateEdit::timerEvent( TQTimerEvent * ) /////////// -class QTimeEditPrivate +class TQTimeEditPrivate { public: int h; @@ -1694,26 +1667,26 @@ public: }; /*! - \class QTimeEdit ExtDatetimeedit.h - \brief The QTimeEdit class provides a time editor. + \class TQTimeEdit ExtDatetimeedit.h + \brief The TQTimeEdit class provides a time editor. \ingroup advanced \ingroup time \mainclass - QTimeEdit allows the user to edit times by using the keyboard or + TQTimeEdit allows the user to edit times by using the keyboard or the arrow keys to increase/decrease time values. The arrow keys - can be used to move from section to section within the QTimeEdit + can be used to move from section to section within the TQTimeEdit box. The user can automatically be moved to the next section once they complete a section using setAutoAdvance(). Times appear in - hour, minute, second order. It is recommended that the QTimeEdit + hour, minute, second order. It is recommended that the TQTimeEdit is initialised with a time, e.g. \code TQTime timeNow = TQTime::currentTime(); - QTimeEdit *timeEdit = new QTimeEdit( timeNow, this ); + TQTimeEdit *timeEdit = new TQTimeEdit( timeNow, this ); timeEdit->setRange( timeNow, timeNow.addSecs( 60 * 60 ) ); \endcode - Here we've created a QTimeEdit widget set to the current time. + Here we've created a TQTimeEdit widget set to the current time. We've also set the minimum value to the current time and the maximum time to one hour from now. @@ -1721,7 +1694,7 @@ public: default to the maximum and minimum values for a TQTime. You can change this by calling setMinValue(), setMaxValue() or setRange(). - Terminology: A QTimeWidget consists of three sections, one each + Terminology: A TQTimeWidget consists of three sections, one each for the hour, minute and second. You can change the separator character using setSeparator(), by default the separator is read from the system's settings. @@ -1733,12 +1706,12 @@ public: // /*! -// Constructs an empty time edit with parent \a parent and called \a +// Constructs an empty time edit with tqparent \a tqparent and called \a // name. // */ // -// QTimeEdit::QTimeEdit( TQWidget * parent, const char * name ) -// : ExtDateTimeEditBase( parent, name ) +// TQTimeEdit::TQTimeEdit( TQWidget * tqparent, const char * name ) +// : ExtDateTimeEditBase( tqparent, name ) // { // init(); // } @@ -1747,11 +1720,11 @@ public: // \overload // // Constructs a time edit with the initial time value, \a time, -// parent \a parent and called \a name. +// tqparent \a tqparent and called \a name. // */ // -// QTimeEdit::QTimeEdit( const TQTime& time, TQWidget * parent, const char * name ) -// : ExtDateTimeEditBase( parent, name ) +// TQTimeEdit::TQTimeEdit( const TQTime& time, TQWidget * tqparent, const char * name ) +// : ExtDateTimeEditBase( tqparent, name ) // { // init(); // setTime( time ); @@ -1760,9 +1733,9 @@ public: // /*! \internal // */ // -// void QTimeEdit::init() +// void TQTimeEdit::init() // { -// d = new QTimeEditPrivate(); +// d = new TQTimeEditPrivate(); // d->ed = new ExtDateTimeEditor( this, "time edit base" ); // d->controls = new ExtDateTimeSpinWidget( this, qstrcmp( name(), "qt_datetime_timeedit" ) == 0 ? "qt_spin_widget" : "time edit controls" ); // d->controls->setEditWidget( d->ed ); @@ -1770,9 +1743,9 @@ public: // connect( d->controls, TQT_SIGNAL( stepUpPressed() ), TQT_SLOT( stepUp() ) ); // connect( d->controls, TQT_SIGNAL( stepDownPressed() ), TQT_SLOT( stepDown() ) ); // -// d->ed->appendSection( QNumberSection( 0,0, TRUE, 0 ) ); -// d->ed->appendSection( QNumberSection( 0,0, TRUE, 1 ) ); -// d->ed->appendSection( QNumberSection( 0,0, TRUE, 2 ) ); +// d->ed->appendSection( TQNumberSection( 0,0, TRUE, 0 ) ); +// d->ed->appendSection( TQNumberSection( 0,0, TRUE, 1 ) ); +// d->ed->appendSection( TQNumberSection( 0,0, TRUE, 2 ) ); // d->ed->setSeparator( localTimeSep() ); // // d->h = 0; @@ -1781,7 +1754,7 @@ public: // d->display = Hours | Minutes | Seconds; // if ( lAMPM ) { // d->display |= AMPM; -// d->ed->appendSection( QNumberSection( 0,0, FALSE, 3 ) ); +// d->ed->appendSection( TQNumberSection( 0,0, FALSE, 3 ) ); // } // d->adv = FALSE; // d->overwrite = TRUE; @@ -1791,7 +1764,7 @@ public: // d->max = TQTime( 23, 59, 59 ); // d->changed = FALSE; // -// setSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed ); +// tqsetSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed ); // // refcount++; // } @@ -1800,7 +1773,7 @@ public: // Destroys the object and frees any allocated resources. // */ // -// QTimeEdit::~QTimeEdit() +// TQTimeEdit::~TQTimeEdit() // { // delete d; // if ( !--refcount ) @@ -1808,33 +1781,33 @@ public: // } // // /*! -// \property QTimeEdit::minValue +// \property TQTimeEdit::minValue // \brief the minimum time value // // Setting the minimum time value is equivalent to calling -// QTimeEdit::setRange( \e t, maxValue() ), where \e t is the minimum +// TQTimeEdit::setRange( \e t, maxValue() ), where \e t is the minimum // time. The default minimum time is 00:00:00. // // \sa maxValue setRange() // */ // -// TQTime QTimeEdit::minValue() const +// TQTime TQTimeEdit::minValue() const // { // return d->min; // } // // /*! -// \property QTimeEdit::maxValue +// \property TQTimeEdit::maxValue // \brief the maximum time value // // Setting the maximum time value is equivalent to calling -// QTimeEdit::setRange( minValue(), \e t ), where \e t is the maximum +// TQTimeEdit::setRange( minValue(), \e t ), where \e t is the maximum // time. The default maximum time is 23:59:59. // // \sa minValue setRange() // */ // -// TQTime QTimeEdit::maxValue() const +// TQTime TQTimeEdit::maxValue() const // { // return d->max; // } @@ -1846,7 +1819,7 @@ public: // Similarly, if \a max is invalid no maximum time is set. // */ // -// void QTimeEdit::setRange( const TQTime& min, const TQTime& max ) +// void TQTimeEdit::setRange( const TQTime& min, const TQTime& max ) // { // if ( min.isValid() ) // d->min = min; @@ -1855,13 +1828,13 @@ public: // } // // /*! -// \property QTimeEdit::display +// \property TQTimeEdit::display // \brief the sections that are displayed in the time edit // // The value can be any combination of the values in the Display enum. // By default, the widget displays hours, minutes and seconds. // */ -// void QTimeEdit::setDisplay( uint display ) +// void TQTimeEdit::setDisplay( uint display ) // { // if ( d->display == display ) // return; @@ -1869,32 +1842,32 @@ public: // d->ed->clearSections(); // d->display = display; // if ( d->display & Hours ) -// d->ed->appendSection( QNumberSection( 0,0, TRUE, 0 ) ); +// d->ed->appendSection( TQNumberSection( 0,0, TRUE, 0 ) ); // if ( d->display & Minutes ) -// d->ed->appendSection( QNumberSection( 0,0, TRUE, 1 ) ); +// d->ed->appendSection( TQNumberSection( 0,0, TRUE, 1 ) ); // if ( d->display & Seconds ) -// d->ed->appendSection( QNumberSection( 0,0, TRUE, 2 ) ); +// d->ed->appendSection( TQNumberSection( 0,0, TRUE, 2 ) ); // if ( d->display & AMPM ) -// d->ed->appendSection( QNumberSection( 0,0, FALSE, 3 ) ); +// d->ed->appendSection( TQNumberSection( 0,0, FALSE, 3 ) ); // // d->ed->setFocusSection( 0 ); // d->ed->update(); // } // -// uint QTimeEdit::display() const +// uint TQTimeEdit::display() const // { // return d->display; // } // // /*! -// \property QTimeEdit::time +// \property TQTimeEdit::time // \brief the editor's time value. // // When changing the time property, if the time is less than // minValue(), or is greater than maxValue(), nothing happens. // */ // -// void QTimeEdit::setTime( const TQTime& time ) +// void TQTimeEdit::setTime( const TQTime& time ) // { // if ( !time.isValid() ) { // d->h = 0; @@ -1909,10 +1882,10 @@ public: // emit valueChanged( time ); // } // d->changed = FALSE; -// d->ed->repaint( d->ed->rect(), FALSE ); +// d->ed->tqrepaint( d->ed->rect(), FALSE ); // } // -// TQTime QTimeEdit::time() const +// TQTime TQTimeEdit::time() const // { // if ( TQTime::isValid( d->h, d->m, d->s ) ) // return TQTime( d->h, d->m, d->s ); @@ -1920,7 +1893,7 @@ public: // } // // /*! -// \property QTimeEdit::autoAdvance +// \property TQTimeEdit::autoAdvance // \brief whether the editor automatically advances to the next // section // @@ -1929,12 +1902,12 @@ public: // The default is FALSE. // */ // -// void QTimeEdit::setAutoAdvance( bool advance ) +// void TQTimeEdit::setAutoAdvance( bool advance ) // { // d->adv = advance; // } // -// bool QTimeEdit::autoAdvance() const +// bool TQTimeEdit::autoAdvance() const // { // return d->adv; // } @@ -1944,7 +1917,7 @@ public: // character of \a s is used. // */ // -// void QTimeEdit::setSeparator( const TQString& s ) +// void TQTimeEdit::setSeparator( const TQString& s ) // { // d->ed->setSeparator( s ); // } @@ -1953,14 +1926,14 @@ public: // Returns the editor's separator. // */ // -// TQString QTimeEdit::separator() const +// TQString TQTimeEdit::separator() const // { // return d->ed->separator(); // } // // // /*! -// \fn void QTimeEdit::valueChanged( const TQTime& time ) +// \fn void TQTimeEdit::valueChanged( const TQTime& time ) // // This signal is emitted whenever the editor's value changes. The \a // time parameter is the new value. @@ -1970,7 +1943,7 @@ public: // // */ // -// bool QTimeEdit::event( TQEvent *e ) +// bool TQTimeEdit::event( TQEvent *e ) // { // if ( e->type() == TQEvent::FocusOut ) { // d->typing = FALSE; @@ -1989,7 +1962,7 @@ public: // // */ // -// void QTimeEdit::timerEvent( TQTimerEvent * ) +// void TQTimeEdit::timerEvent( TQTimerEvent * ) // { // d->overwrite = TRUE; // } @@ -1999,7 +1972,7 @@ public: // // */ // -// void QTimeEdit::stepUp() +// void TQTimeEdit::stepUp() // { // int sec = d->ed->mapSection( d->ed->focusSection() ); // bool accepted = TRUE; @@ -2030,8 +2003,8 @@ public: // break; // default: // accepted = FALSE; -// #ifdef QT_CHECK_RANGE -// qWarning( "QTimeEdit::stepUp: Focus section out of range!" ); +// #ifdef TQT_CHECK_RANGE +// qWarning( "TQTimeEdit::stepUp: Focus section out of range!" ); // #endif // break; // } @@ -2039,7 +2012,7 @@ public: // d->changed = TRUE; // emit valueChanged( time() ); // } -// d->ed->repaint( d->ed->rect(), FALSE ); +// d->ed->tqrepaint( d->ed->rect(), FALSE ); // } // // @@ -2047,7 +2020,7 @@ public: // // */ // -// void QTimeEdit::stepDown() +// void TQTimeEdit::stepDown() // { // int sec = d->ed->mapSection( d->ed->focusSection() ); // @@ -2079,8 +2052,8 @@ public: // break; // default: // accepted = FALSE; -// #ifdef QT_CHECK_RANGE -// qWarning( "QTimeEdit::stepDown: Focus section out of range!" ); +// #ifdef TQT_CHECK_RANGE +// qWarning( "TQTimeEdit::stepDown: Focus section out of range!" ); // #endif // break; // } @@ -2088,7 +2061,7 @@ public: // d->changed = TRUE; // emit valueChanged( time() ); // } -// d->ed->repaint( d->ed->rect(), FALSE ); +// d->ed->tqrepaint( d->ed->rect(), FALSE ); // } // // @@ -2098,7 +2071,7 @@ public: // on \a sec. // */ // -// TQString QTimeEdit::sectionFormattedText( int sec ) +// TQString TQTimeEdit::sectionFormattedText( int sec ) // { // TQString txt; // txt = sectionText( sec ); @@ -2117,7 +2090,7 @@ public: // // */ // -// bool QTimeEdit::setFocusSection( int sec ) +// bool TQTimeEdit::setFocusSection( int sec ) // { // if ( sec != d->ed->focusSection() ) { // killTimer( d->timerId ); @@ -2141,7 +2114,7 @@ public: // range 0..24. // */ // -// void QTimeEdit::setHour( int h ) +// void TQTimeEdit::setHour( int h ) // { // if ( h < 0 ) // h = 0; @@ -2156,7 +2129,7 @@ public: // range 0..59. // */ // -// void QTimeEdit::setMinute( int m ) +// void TQTimeEdit::setMinute( int m ) // { // if ( m < 0 ) // m = 0; @@ -2171,7 +2144,7 @@ public: // range 0..59. // */ // -// void QTimeEdit::setSecond( int s ) +// void TQTimeEdit::setSecond( int s ) // { // if ( s < 0 ) // s = 0; @@ -2187,7 +2160,7 @@ public: // // */ // -// TQString QTimeEdit::sectionText( int sec ) +// TQString TQTimeEdit::sectionText( int sec ) // { // sec = d->ed->mapSection( sec ); // @@ -2214,12 +2187,12 @@ public: // if ( lAM ) // txt = *lAM; // else -// txt = TQString::fromLatin1( "AM" ); +// txt = TQString::tqfromLatin1( "AM" ); // } else { // if ( lPM ) // txt = *lPM; // else -// txt = TQString::fromLatin1( "PM" ); +// txt = TQString::tqfromLatin1( "PM" ); // } // break; // default: @@ -2233,7 +2206,7 @@ public: // Returns TRUE if \a h, \a m, and \a s are out of range. // */ // -// bool QTimeEdit::outOfRange( int h, int m, int s ) const +// bool TQTimeEdit::outOfRange( int h, int m, int s ) const // { // if ( TQTime::isValid( h, m, s ) ) { // TQTime currentTime( h, m, s ); @@ -2250,7 +2223,7 @@ public: // // */ // -// void QTimeEdit::addNumber( int sec, int num ) +// void TQTimeEdit::addNumber( int sec, int num ) // { // if ( sec == -1 ) // return; @@ -2369,8 +2342,8 @@ public: // if ( accepted ) // emit valueChanged( time() ); // d->overwrite = overwrite; -// d->timerId = startTimer( qApp->doubleClickInterval()*4 ); -// d->ed->repaint( d->ed->rect(), FALSE ); +// d->timerId = startTimer( tqApp->doubleClickInterval()*4 ); +// d->ed->tqrepaint( d->ed->rect(), FALSE ); // } // // @@ -2381,7 +2354,7 @@ public: // remove the first number from \a sec by pressing the backspace key. // */ // -// void QTimeEdit::removeFirstNumber( int sec ) +// void TQTimeEdit::removeFirstNumber( int sec ) // { // if ( sec == -1 ) // return; @@ -2410,13 +2383,13 @@ public: // d->s = txt.toInt(); // break; // } -// d->ed->repaint( d->ed->rect(), FALSE ); +// d->ed->tqrepaint( d->ed->rect(), FALSE ); // } // // /*! \reimp // // */ -// void QTimeEdit::removeLastNumber( int sec ) +// void TQTimeEdit::removeLastNumber( int sec ) // { // if ( sec == -1 ) // return; @@ -2445,23 +2418,23 @@ public: // d->s = txt.toInt(); // break; // } -// d->ed->repaint( d->ed->rect(), FALSE ); +// d->ed->tqrepaint( d->ed->rect(), FALSE ); // } // // /*! \reimp // */ -// void QTimeEdit::resizeEvent( TQResizeEvent * ) +// void TQTimeEdit::resizeEvent( TQResizeEvent * ) // { // d->controls->resize( width(), height() ); // } // // /*! \reimp // */ -// TQSize QTimeEdit::sizeHint() const +// TQSize TQTimeEdit::tqsizeHint() const // { // constPolish(); // TQFontMetrics fm( font() ); -// int fw = style().pixelMetric( TQStyle::PM_DefaultFrameWidth, this ); +// int fw = tqstyle().tqpixelMetric( TQStyle::PM_DefaultFrameWidth, this ); // int h = fm.lineSpacing() + 2; // int w = 2 + fm.width( '9' ) * 6 + fm.width( d->ed->separator() ) * 2 + // d->controls->upRect().width() + fw * 4; @@ -2469,17 +2442,17 @@ public: // if ( lAM ) // w += fm.width( *lAM ) + 4; // else -// w += fm.width( TQString::fromLatin1( "AM" ) ) + 4; +// w += fm.width( TQString::tqfromLatin1( "AM" ) ) + 4; // } // -// return TQSize( w, QMAX(h + fw * 2,20) ).expandedTo( TQApplication::globalStrut() ); +// return TQSize( w, TQMAX(h + fw * 2,20) ).expandedTo( TQApplication::globalStrut() ); // } // // /*! \reimp // */ -// TQSize QTimeEdit::minimumSizeHint() const +// TQSize TQTimeEdit::tqminimumSizeHint() const // { -// return sizeHint(); +// return tqsizeHint(); // } // // /*! @@ -2490,7 +2463,7 @@ public: // // // ### Remove in 4.0? // -// void QTimeEdit::updateButtons() +// void TQTimeEdit::updateButtons() // { // if ( !isEnabled() ) // return; @@ -2511,13 +2484,13 @@ public: /*! \class ExtDateTimeEdit ExtDatetimeedit.h - \brief The ExtDateTimeEdit class combines a ExtDateEdit and QTimeEdit + \brief The ExtDateTimeEdit class combines a ExtDateEdit and TQTimeEdit widget into a single widget for editing datetimes. \ingroup advanced \ingroup time - ExtDateTimeEdit consists of a ExtDateEdit and QTimeEdit widget placed + ExtDateTimeEdit consists of a ExtDateEdit and TQTimeEdit widget placed side by side and offers the functionality of both. The user can edit the date and time by using the keyboard or the arrow keys to increase/decrease date or time values. The Tab key can be used to @@ -2534,16 +2507,16 @@ public: It is recommended that the ExtDateTimeEdit is initialised with a datetime, e.g. \code - ExtDateTimeEdit *dateTimeEdit = new ExtDateTimeEdit( ExtDateTime::currentDateTime(), this ); - dateTimeEdit->dateEdit()->setRange( ExtDateTime::currentDate(), - ExtDateTime::currentDate().addDays( 7 ) ); + ExtDateTimeEdit *dateTimeEdit = new ExtDateTimeEdit( ExtDateTime::tqcurrentDateTime(), this ); + dateTimeEdit->dateEdit()->setRange( ExtDateTime::tqcurrentDate(), + ExtDateTime::tqcurrentDate().addDays( 7 ) ); \endcode Here we've created a new ExtDateTimeEdit set to the current date and time, and set the date to have a minimum date of now and a maximum date of a week from now. Terminology: A ExtDateEdit widget consists of three 'sections', one - each for the year, month and day. Similarly a QTimeEdit consists + each for the year, month and day. Similarly a TQTimeEdit consists of three sections, one each for the hour, minute and second. The character that separates each date section is specified with setDateSeparator(); similarly setTimeSeparator() is used for the @@ -2551,15 +2524,15 @@ public: \image html datetimewidgets.png "Date Time Widgets" - \sa ExtDateEdit QTimeEdit + \sa ExtDateEdit TQTimeEdit */ /*! - Constructs an empty datetime edit with parent \a parent and called + Constructs an empty datetime edit with tqparent \a tqparent and called \a name. */ -ExtDateTimeEdit::ExtDateTimeEdit( TQWidget * parent, const char * name ) - : TQWidget( parent, name ) +ExtDateTimeEdit::ExtDateTimeEdit( TQWidget * tqparent, const char * name ) + : TQWidget( tqparent, name ) { init(); } @@ -2569,11 +2542,11 @@ ExtDateTimeEdit::ExtDateTimeEdit( TQWidget * parent, const char * name ) \overload Constructs a datetime edit with the initial value \a datetime, - parent \a parent and called \a name. + tqparent \a tqparent and called \a name. */ ExtDateTimeEdit::ExtDateTimeEdit( const ExtDateTime& datetime, - TQWidget * parent, const char * name ) - : TQWidget( parent, name ) + TQWidget * tqparent, const char * name ) + : TQWidget( tqparent, name ) { init(); setDateTime( datetime ); @@ -2600,8 +2573,8 @@ ExtDateTimeEdit::~ExtDateTimeEdit() void ExtDateTimeEdit::resizeEvent( TQResizeEvent * ) { - int dw = de->sizeHint().width(); - int tw = te->sizeHint().width(); + int dw = de->tqsizeHint().width(); + int tw = te->tqsizeHint().width(); int w = width(); int h = height(); int extra = w - ( dw + tw ); @@ -2620,12 +2593,12 @@ void ExtDateTimeEdit::resizeEvent( TQResizeEvent * ) /*! \reimp */ -TQSize ExtDateTimeEdit::minimumSizeHint() const +TQSize ExtDateTimeEdit::tqminimumSizeHint() const { - TQSize dsh = de->minimumSizeHint(); - TQSize tsh = te->minimumSizeHint(); + TQSize dsh = de->tqminimumSizeHint(); + TQSize tsh = te->tqminimumSizeHint(); return TQSize( dsh.width() + tsh.width(), - QMAX( dsh.height(), tsh.height() ) ); + TQMAX( dsh.height(), tsh.height() ) ); } /*! \internal @@ -2635,26 +2608,26 @@ void ExtDateTimeEdit::init() { d = new ExtDateTimeEditPrivate(); de = new ExtDateEdit( this, "qt_datetime_dateedit" ); - te = new QTimeEdit( this, "qt_datetime_timeedit" ); + te = new TQTimeEdit( this, "qt_datetime_timeedit" ); d->adv = FALSE; connect( de, TQT_SIGNAL( valueChanged( const ExtDate& ) ), this, TQT_SLOT( newValue( const ExtDate& ) ) ); connect( te, TQT_SIGNAL( valueChanged( const TQTime& ) ), this, TQT_SLOT( newValue( const TQTime& ) ) ); setFocusProxy( de ); - setSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed ); + tqsetSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Fixed ); } /*! \reimp */ -TQSize ExtDateTimeEdit::sizeHint() const +TQSize ExtDateTimeEdit::tqsizeHint() const { constPolish(); - TQSize dsh = de->sizeHint(); - TQSize tsh = te->sizeHint(); + TQSize dsh = de->tqsizeHint(); + TQSize tsh = te->tqsizeHint(); return TQSize( dsh.width() + tsh.width(), - QMAX( dsh.height(), tsh.height() ) ); + TQMAX( dsh.height(), tsh.height() ) ); } /*! @@ -2740,7 +2713,7 @@ bool ExtDateTimeEdit::autoAdvance() const */ /*! - \fn QTimeEdit* ExtDateTimeEdit::timeEdit() + \fn TQTimeEdit* ExtDateTimeEdit::timeEdit() Returns the internal widget used for editing the time part of the datetime. |