From ffe8a83e053396df448e9413828527613ca3bd46 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 31 Jul 2010 19:46:43 +0000 Subject: Trinity Qt initial conversion git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1157647 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- khtml/rendering/render_form.cpp | 280 ++++++++++++++++++++-------------------- 1 file changed, 140 insertions(+), 140 deletions(-) (limited to 'khtml/rendering/render_form.cpp') diff --git a/khtml/rendering/render_form.cpp b/khtml/rendering/render_form.cpp index f8daba1e3..403295a8f 100644 --- a/khtml/rendering/render_form.cpp +++ b/khtml/rendering/render_form.cpp @@ -38,7 +38,7 @@ #include #include -#include +#include #include "misc/helper.h" #include "xml/dom2_eventsimpl.h" @@ -52,8 +52,8 @@ #include "khtml_ext.h" #include "xml/dom_docimpl.h" -#include -#include +#include +#include using namespace khtml; @@ -138,7 +138,7 @@ short RenderButton::baselinePosition( bool f ) const RenderCheckBox::RenderCheckBox(HTMLInputElementImpl *element) : RenderButton(element) { - QCheckBox* b = new QCheckBox(view()->viewport(), "__khtml"); + TQCheckBox* b = new TQCheckBox(view()->viewport(), "__khtml"); b->setAutoMask(true); b->setMouseTracking(true); setQWidget(b); @@ -146,7 +146,7 @@ RenderCheckBox::RenderCheckBox(HTMLInputElementImpl *element) // prevent firing toggled() signals on initialization b->setChecked(element->checked()); - connect(b,SIGNAL(stateChanged(int)),this,SLOT(slotStateChanged(int))); + connect(b,TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(slotStateChanged(int))); } @@ -154,9 +154,9 @@ void RenderCheckBox::calcMinMaxWidth() { KHTMLAssert( !minMaxKnown() ); - QCheckBox *cb = static_cast( m_widget ); - QSize s( cb->style().pixelMetric( QStyle::PM_IndicatorWidth ), - cb->style().pixelMetric( QStyle::PM_IndicatorHeight ) ); + TQCheckBox *cb = static_cast( m_widget ); + TQSize s( cb->style().pixelMetric( TQStyle::PM_IndicatorWidth ), + cb->style().pixelMetric( TQStyle::PM_IndicatorHeight ) ); setIntrinsicWidth( s.width() ); setIntrinsicHeight( s.height() ); @@ -172,8 +172,8 @@ void RenderCheckBox::updateFromElement() void RenderCheckBox::slotStateChanged(int state) { - element()->setChecked(state == QButton::On); - element()->setIndeterminate(state == QButton::NoChange); + element()->setChecked(state == TQButton::On); + element()->setIndeterminate(state == TQButton::NoChange); ref(); element()->onChange(); @@ -185,14 +185,14 @@ void RenderCheckBox::slotStateChanged(int state) RenderRadioButton::RenderRadioButton(HTMLInputElementImpl *element) : RenderButton(element) { - QRadioButton* b = new QRadioButton(view()->viewport(), "__khtml"); + TQRadioButton* b = new TQRadioButton(view()->viewport(), "__khtml"); b->setMouseTracking(true); setQWidget(b); // prevent firing toggled() signals on initialization b->setChecked(element->checked()); - connect(b,SIGNAL(toggled(bool)),this,SLOT(slotToggled(bool))); + connect(b,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(slotToggled(bool))); } void RenderRadioButton::updateFromElement() @@ -206,9 +206,9 @@ void RenderRadioButton::calcMinMaxWidth() { KHTMLAssert( !minMaxKnown() ); - QRadioButton *rb = static_cast( m_widget ); - QSize s( rb->style().pixelMetric( QStyle::PM_ExclusiveIndicatorWidth ), - rb->style().pixelMetric( QStyle::PM_ExclusiveIndicatorHeight ) ); + TQRadioButton *rb = static_cast( m_widget ); + TQSize s( rb->style().pixelMetric( TQStyle::PM_ExclusiveIndicatorWidth ), + rb->style().pixelMetric( TQStyle::PM_ExclusiveIndicatorHeight ) ); setIntrinsicWidth( s.width() ); setIntrinsicHeight( s.height() ); @@ -230,17 +230,17 @@ void RenderRadioButton::slotToggled(bool activated) RenderSubmitButton::RenderSubmitButton(HTMLInputElementImpl *element) : RenderButton(element) { - QPushButton* p = new QPushButton(view()->viewport(), "__khtml"); + TQPushButton* p = new TQPushButton(view()->viewport(), "__khtml"); setQWidget(p); p->setAutoMask(true); p->setMouseTracking(true); } -QString RenderSubmitButton::rawText() +TQString RenderSubmitButton::rawText() { - QString value = element()->valueWithDefault().string(); + TQString value = element()->valueWithDefault().string(); value = value.stripWhiteSpace(); - QString raw; + TQString raw; for(unsigned int i = 0; i < value.length(); i++) { raw += value[i]; if(value[i] == '&') @@ -253,29 +253,29 @@ void RenderSubmitButton::calcMinMaxWidth() { KHTMLAssert( !minMaxKnown() ); - QString raw = rawText(); - QPushButton* pb = static_cast(m_widget); + TQString raw = rawText(); + TQPushButton* pb = static_cast(m_widget); pb->setText(raw); pb->setFont(style()->font()); bool empty = raw.isEmpty(); if ( empty ) - raw = QString::fromLatin1("X"); - QFontMetrics fm = pb->fontMetrics(); - QSize ts = fm.size( ShowPrefix, raw); - QSize s(pb->style().sizeFromContents( QStyle::CT_PushButton, pb, ts ) - .expandedTo(QApplication::globalStrut())); - int margin = pb->style().pixelMetric( QStyle::PM_ButtonMargin, pb) + - pb->style().pixelMetric( QStyle::PM_DefaultFrameWidth, pb ) * 2; + raw = TQString::fromLatin1("X"); + TQFontMetrics fm = pb->fontMetrics(); + TQSize ts = fm.size( ShowPrefix, raw); + TQSize s(pb->style().sizeFromContents( TQStyle::CT_PushButton, pb, ts ) + .expandedTo(TQApplication::globalStrut())); + int margin = pb->style().pixelMetric( TQStyle::PM_ButtonMargin, pb) + + pb->style().pixelMetric( TQStyle::PM_DefaultFrameWidth, pb ) * 2; int w = ts.width() + margin; int h = s.height(); if (pb->isDefault() || pb->autoDefault()) { - int dbw = pb->style().pixelMetric( QStyle::PM_ButtonDefaultIndicator, pb ) * 2; + int dbw = pb->style().pixelMetric( TQStyle::PM_ButtonDefaultIndicator, pb ) * 2; w += dbw; } // add 30% margins to the width (heuristics to make it look similar to IE) - s = QSize( w*13/10, h ).expandedTo(QApplication::globalStrut()); + s = TQSize( w*13/10, h ).expandedTo(TQApplication::globalStrut()); setIntrinsicWidth( s.width() ); setIntrinsicHeight( s.height() ); @@ -285,9 +285,9 @@ void RenderSubmitButton::calcMinMaxWidth() void RenderSubmitButton::updateFromElement() { - QString oldText = static_cast(m_widget)->text(); - QString newText = rawText(); - static_cast(m_widget)->setText(newText); + TQString oldText = static_cast(m_widget)->text(); + TQString newText = rawText(); + static_cast(m_widget)->setText(newText); if ( oldText != newText ) setNeedsLayoutAndMinMaxRecalc(); RenderFormElement::updateFromElement(); @@ -307,12 +307,12 @@ RenderResetButton::RenderResetButton(HTMLInputElementImpl *element) // ------------------------------------------------------------------------------- -LineEditWidget::LineEditWidget(DOM::HTMLInputElementImpl* input, KHTMLView* view, QWidget* parent) +LineEditWidget::LineEditWidget(DOM::HTMLInputElementImpl* input, KHTMLView* view, TQWidget* parent) : KLineEdit(parent, "__khtml"), m_input(input), m_view(view), m_spell(0) { setMouseTracking(true); KActionCollection *ac = new KActionCollection(this); - m_spellAction = KStdAction::spelling( this, SLOT( slotCheckSpelling() ), ac ); + m_spellAction = KStdAction::spelling( this, TQT_SLOT( slotCheckSpelling() ), ac ); } LineEditWidget::~LineEditWidget() @@ -328,14 +328,14 @@ void LineEditWidget::slotCheckSpelling() } delete m_spell; - m_spell = new KSpell( this, i18n( "Spell Checking" ), this, SLOT( slotSpellCheckReady( KSpell *) ), 0, true, true); + m_spell = new KSpell( this, i18n( "Spell Checking" ), this, TQT_SLOT( slotSpellCheckReady( KSpell *) ), 0, true, true); - connect( m_spell, SIGNAL( death() ),this, SLOT( spellCheckerFinished() ) ); - connect( m_spell, SIGNAL( misspelling( const QString &, const QStringList &, unsigned int ) ),this, SLOT( spellCheckerMisspelling( const QString &, const QStringList &, unsigned int ) ) ); - connect( m_spell, SIGNAL( corrected( const QString &, const QString &, unsigned int ) ),this, SLOT( spellCheckerCorrected( const QString &, const QString &, unsigned int ) ) ); + connect( m_spell, TQT_SIGNAL( death() ),this, TQT_SLOT( spellCheckerFinished() ) ); + connect( m_spell, TQT_SIGNAL( misspelling( const TQString &, const TQStringList &, unsigned int ) ),this, TQT_SLOT( spellCheckerMisspelling( const TQString &, const TQStringList &, unsigned int ) ) ); + connect( m_spell, TQT_SIGNAL( corrected( const TQString &, const TQString &, unsigned int ) ),this, TQT_SLOT( spellCheckerCorrected( const TQString &, const TQString &, unsigned int ) ) ); } -void LineEditWidget::spellCheckerMisspelling( const QString &_text, const QStringList &, unsigned int pos) +void LineEditWidget::spellCheckerMisspelling( const TQString &_text, const TQStringList &, unsigned int pos) { highLightWord( _text.length(),pos ); } @@ -345,7 +345,7 @@ void LineEditWidget::highLightWord( unsigned int length, unsigned int pos ) setSelection ( pos, length ); } -void LineEditWidget::spellCheckerCorrected( const QString &old, const QString &corr, unsigned int pos ) +void LineEditWidget::spellCheckerCorrected( const TQString &old, const TQString &corr, unsigned int pos ) { if( old!= corr ) { @@ -362,26 +362,26 @@ void LineEditWidget::spellCheckerFinished() void LineEditWidget::slotSpellCheckReady( KSpell *s ) { s->check( text() ); - connect( s, SIGNAL( done( const QString & ) ), this, SLOT( slotSpellCheckDone( const QString & ) ) ); + connect( s, TQT_SIGNAL( done( const TQString & ) ), this, TQT_SLOT( slotSpellCheckDone( const TQString & ) ) ); } -void LineEditWidget::slotSpellCheckDone( const QString &s ) +void LineEditWidget::slotSpellCheckDone( const TQString &s ) { if( s != text() ) setText( s ); } -QPopupMenu *LineEditWidget::createPopupMenu() +TQPopupMenu *LineEditWidget::createPopupMenu() { - QPopupMenu *popup = KLineEdit::createPopupMenu(); + TQPopupMenu *popup = KLineEdit::createPopupMenu(); if ( !popup ) { return 0L; } - connect( popup, SIGNAL( activated( int ) ), - this, SLOT( extendedMenuActivated( int ) ) ); + connect( popup, TQT_SIGNAL( activated( int ) ), + this, TQT_SLOT( extendedMenuActivated( int ) ) ); if (m_input->autoComplete()) { popup->insertSeparator(); @@ -389,7 +389,7 @@ QPopupMenu *LineEditWidget::createPopupMenu() popup->setItemEnabled( id, (compObj() && !compObj()->isEmpty()) ); } - if (echoMode() == QLineEdit::Normal && + if (echoMode() == TQLineEdit::Normal && !isReadOnly()) { popup->insertSeparator(); @@ -414,13 +414,13 @@ void LineEditWidget::extendedMenuActivated( int id) } } -bool LineEditWidget::event( QEvent *e ) +bool LineEditWidget::event( TQEvent *e ) { if (KLineEdit::event(e)) return true; - if ( e->type() == QEvent::AccelAvailable && isReadOnly() ) { - QKeyEvent* ke = (QKeyEvent*) e; + if ( e->type() == TQEvent::AccelAvailable && isReadOnly() ) { + TQKeyEvent* ke = (TQKeyEvent*) e; if ( ke->state() & ControlButton ) { switch ( ke->key() ) { case Key_Left: @@ -438,7 +438,7 @@ bool LineEditWidget::event( QEvent *e ) return false; } -void LineEditWidget::mouseMoveEvent(QMouseEvent *e) +void LineEditWidget::mouseMoveEvent(TQMouseEvent *e) { // hack to prevent Qt from calling setCursor on the widget setDragEnabled(false); @@ -453,14 +453,14 @@ RenderLineEdit::RenderLineEdit(HTMLInputElementImpl *element) : RenderFormElement(element) { LineEditWidget *edit = new LineEditWidget(element, view(), view()->viewport()); - connect(edit,SIGNAL(returnPressed()), this, SLOT(slotReturnPressed())); - connect(edit,SIGNAL(textChanged(const QString &)),this,SLOT(slotTextChanged(const QString &))); + connect(edit,TQT_SIGNAL(returnPressed()), this, TQT_SLOT(slotReturnPressed())); + connect(edit,TQT_SIGNAL(textChanged(const TQString &)),this,TQT_SLOT(slotTextChanged(const TQString &))); if(element->inputType() == HTMLInputElementImpl::PASSWORD) - edit->setEchoMode( QLineEdit::Password ); + edit->setEchoMode( TQLineEdit::Password ); if ( element->autoComplete() ) { - QStringList completions = view()->formCompletionItems(element->name().string()); + TQStringList completions = view()->formCompletionItems(element->name().string()); if (completions.count()) { edit->completionObject()->setItems(completions); edit->setContextMenuEnabled(true); @@ -518,16 +518,16 @@ void RenderLineEdit::calcMinMaxWidth() { KHTMLAssert( !minMaxKnown() ); - const QFontMetrics &fm = style()->fontMetrics(); - QSize s; + const TQFontMetrics &fm = style()->fontMetrics(); + TQSize s; int size = element()->size(); int h = fm.lineSpacing(); int w = fm.width( 'x' ) * (size > 0 ? size+1 : 17); // "some" - s = QSize(w + 2 + 2*widget()->frameWidth(), + s = TQSize(w + 2 + 2*widget()->frameWidth(), kMax(h, 14) + 2 + 2*widget()->frameWidth()) - .expandedTo(QApplication::globalStrut()); + .expandedTo(TQApplication::globalStrut()); setIntrinsicWidth( s.width() ); setIntrinsicHeight( s.height() ); @@ -560,7 +560,7 @@ void RenderLineEdit::updateFromElement() RenderFormElement::updateFromElement(); } -void RenderLineEdit::slotTextChanged(const QString &string) +void RenderLineEdit::slotTextChanged(const TQString &string) { // don't use setValue here! element()->m_value = string; @@ -679,12 +679,12 @@ void RenderFieldset::paintBoxDecorations(PaintInfo& pI, int _tx, int _ty) paintBorderMinusLegend(pI.p, _tx, _ty, w, h, style(), legend->xPos(), legend->width()); } -void RenderFieldset::paintBorderMinusLegend(QPainter *p, int _tx, int _ty, int w, int h, +void RenderFieldset::paintBorderMinusLegend(TQPainter *p, int _tx, int _ty, int w, int h, const RenderStyle* style, int lx, int lw) { - const QColor& tc = style->borderTopColor(); - const QColor& bc = style->borderBottomColor(); + const TQColor& tc = style->borderTopColor(); + const TQColor& bc = style->borderBottomColor(); EBorderStyle ts = style->borderTopStyle(); EBorderStyle bs = style->borderBottomStyle(); @@ -710,7 +710,7 @@ void RenderFieldset::paintBorderMinusLegend(QPainter *p, int _tx, int _ty, int w if(render_l) { - const QColor& lc = style->borderLeftColor(); + const TQColor& lc = style->borderLeftColor(); bool ignore_top = (tc == lc) && @@ -729,7 +729,7 @@ void RenderFieldset::paintBorderMinusLegend(QPainter *p, int _tx, int _ty, int w if(render_r) { - const QColor& rc = style->borderRightColor(); + const TQColor& rc = style->borderRightColor(); bool ignore_top = (tc == rc) && @@ -769,9 +769,9 @@ RenderFileButton::RenderFileButton(HTMLInputElementImpl *element) w->setMode(KFile::File | KFile::ExistingOnly); w->completionObject()->setDir(KGlobalSettings::documentPath()); - connect(w->lineEdit(), SIGNAL(returnPressed()), this, SLOT(slotReturnPressed())); - connect(w->lineEdit(), SIGNAL(textChanged(const QString &)),this,SLOT(slotTextChanged(const QString &))); - connect(w, SIGNAL(urlSelected(const QString &)),this,SLOT(slotUrlSelected(const QString &))); + connect(w->lineEdit(), TQT_SIGNAL(returnPressed()), this, TQT_SLOT(slotReturnPressed())); + connect(w->lineEdit(), TQT_SIGNAL(textChanged(const TQString &)),this,TQT_SLOT(slotTextChanged(const TQString &))); + connect(w, TQT_SIGNAL(urlSelected(const TQString &)),this,TQT_SLOT(slotUrlSelected(const TQString &))); setQWidget(w); m_haveFocus = false; @@ -783,17 +783,17 @@ void RenderFileButton::calcMinMaxWidth() { KHTMLAssert( !minMaxKnown() ); - const QFontMetrics &fm = style()->fontMetrics(); + const TQFontMetrics &fm = style()->fontMetrics(); int size = element()->size(); int h = fm.lineSpacing(); int w = fm.width( 'x' ) * (size > 0 ? size+1 : 17); // "some" KLineEdit* edit = static_cast( m_widget )->lineEdit(); - QSize s = edit->style().sizeFromContents(QStyle::CT_LineEdit, + TQSize s = edit->style().sizeFromContents(TQStyle::CT_LineEdit, edit, - QSize(w + 2 + 2*edit->frameWidth(), kMax(h, 14) + 2 + 2*edit->frameWidth())) - .expandedTo(QApplication::globalStrut()); - QSize bs = static_cast( m_widget )->minimumSizeHint() - edit->minimumSizeHint(); + TQSize(w + 2 + 2*edit->frameWidth(), kMax(h, 14) + 2 + 2*edit->frameWidth())) + .expandedTo(TQApplication::globalStrut()); + TQSize bs = static_cast( m_widget )->minimumSizeHint() - edit->minimumSizeHint(); setIntrinsicWidth( s.width() + bs.width() ); setIntrinsicHeight( kMax(s.height(), bs.height()) ); @@ -828,12 +828,12 @@ void RenderFileButton::slotReturnPressed() element()->form()->submitFromKeyboard(); } -void RenderFileButton::slotTextChanged(const QString &/*string*/) +void RenderFileButton::slotTextChanged(const TQString &/*string*/) { element()->m_value = KURL( widget()->url() ).prettyURL( 0, KURL::StripFileProtocol ); } -void RenderFileButton::slotUrlSelected(const QString &) +void RenderFileButton::slotUrlSelected(const TQString &) { element()->onChange(); } @@ -860,7 +860,7 @@ RenderLegend::RenderLegend(HTMLGenericFormElementImpl *element) // ------------------------------------------------------------------------------- -ComboBoxWidget::ComboBoxWidget(QWidget *parent) +ComboBoxWidget::ComboBoxWidget(TQWidget *parent) : KComboBox(false, parent, "__khtml") { setAutoMask(true); @@ -868,13 +868,13 @@ ComboBoxWidget::ComboBoxWidget(QWidget *parent) setMouseTracking(true); } -bool ComboBoxWidget::event(QEvent *e) +bool ComboBoxWidget::event(TQEvent *e) { if (KComboBox::event(e)) return true; - if (e->type()==QEvent::KeyPress) + if (e->type()==TQEvent::KeyPress) { - QKeyEvent *ke = static_cast(e); + TQKeyEvent *ke = static_cast(e); switch(ke->key()) { case Key_Return: @@ -889,21 +889,21 @@ bool ComboBoxWidget::event(QEvent *e) return false; } -bool ComboBoxWidget::eventFilter(QObject *dest, QEvent *e) +bool ComboBoxWidget::eventFilter(TQObject *dest, TQEvent *e) { - if (dest==listBox() && e->type()==QEvent::KeyPress) + if (dest==listBox() && e->type()==TQEvent::KeyPress) { - QKeyEvent *ke = static_cast(e); + TQKeyEvent *ke = static_cast(e); bool forward = false; switch(ke->key()) { case Key_Tab: forward=true; case Key_BackTab: - // ugly hack. emulate popdownlistbox() (private in QComboBox) + // ugly hack. emulate popdownlistbox() (private in TQComboBox) // we re-use ke here to store the reference to the generated event. - ke = new QKeyEvent(QEvent::KeyPress, Key_Escape, 0, 0); - QApplication::sendEvent(dest,ke); + ke = new TQKeyEvent(TQEvent::KeyPress, Key_Escape, 0, 0); + TQApplication::sendEvent(dest,ke); focusNextPrevChild(forward); delete ke; return true; @@ -955,7 +955,7 @@ void RenderSelect::updateFromElement() } if (m_useListBox && oldMultiple != m_multiple) { - static_cast(m_widget)->setSelectionMode(m_multiple ? QListBox::Extended : QListBox::Single); + static_cast(m_widget)->setSelectionMode(m_multiple ? TQListBox::Extended : TQListBox::Single); } m_selectionChanged = true; m_optionsChanged = true; @@ -965,7 +965,7 @@ void RenderSelect::updateFromElement() if ( m_optionsChanged ) { if (element()->m_recalcListItems) element()->recalcListItems(); - QMemArray listItems = element()->listItems(); + TQMemArray listItems = element()->listItems(); int listIndex; if(m_useListBox) { @@ -982,27 +982,27 @@ void RenderSelect::updateFromElement() text = ""; if(m_useListBox) { - QListBoxText *item = new QListBoxText(QString(text.implementation()->s, text.implementation()->l)); + TQListBoxText *item = new TQListBoxText(TQString(text.implementation()->s, text.implementation()->l)); static_cast(m_widget) ->insertItem(item, listIndex); item->setSelectable(false); } else { static_cast(m_widget) - ->insertItem(QString(text.implementation()->s, text.implementation()->l), listIndex); + ->insertItem(TQString(text.implementation()->s, text.implementation()->l), listIndex); static_cast(m_widget)->listBox()->item(listIndex)->setSelectable(false); } } else if (listItems[listIndex]->id() == ID_OPTION) { HTMLOptionElementImpl* optElem = static_cast(listItems[listIndex]); - QString text = optElem->text().string(); + TQString text = optElem->text().string(); if (optElem->parentNode()->id() == ID_OPTGROUP) { // Prefer label if set DOMString label = optElem->getAttribute(ATTR_LABEL); if (!label.isEmpty()) text = label.string(); - text = QString::fromLatin1(" ")+text; + text = TQString::fromLatin1(" ")+text; } if(m_useListBox) { @@ -1020,7 +1020,7 @@ void RenderSelect::updateFromElement() m_selectionChanged = true; } - // QComboBox caches the size hint unless you call setFont (ref: TT docu) + // TQComboBox caches the size hint unless you call setFont (ref: TT docu) if(!m_useListBox) { KComboBox *that = static_cast(m_widget); that->setFont( that->font() ); @@ -1069,7 +1069,7 @@ void RenderSelect::layout( ) if(m_useListBox) { KListBox* w = static_cast(m_widget); - QListBoxItem* p = w->firstItem(); + TQListBoxItem* p = w->firstItem(); int width = 0; int height = 0; while(p) { @@ -1098,7 +1098,7 @@ void RenderSelect::layout( ) setIntrinsicHeight( height ); } else { - QSize s(m_widget->sizeHint()); + TQSize s(m_widget->sizeHint()); setIntrinsicWidth( s.width() ); setIntrinsicHeight( s.height() ); } @@ -1108,7 +1108,7 @@ void RenderSelect::layout( ) RenderFormElement::layout(); // and now disable the widget in case there is no