Changeset 611 for tests/widget/widget.cpp
- Timestamp:
- Feb 26, 2010, 7:49:00 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/widget/widget.cpp
r536 r611 3 3 #include <QtGui> 4 4 5 #ifndef Q_WS_PM6 7 // For printing non-quoted QString's with QDebug)8 struct QDbgStr: public QString9 {10 inline QDbgStr(const QString &str) : QString(str) {}11 };12 13 // Prints a non-quoted QString14 inline QDebug operator<<(QDebug dbg, const QDbgStr &str)15 { dbg << str.toUtf8().constData(); return dbg; }16 17 QDbgStr qWidgetName(QWidget *w)18 {19 if (w)20 return QString()21 .sprintf("%s.%s", w->metaObject()->className(),22 w->objectName().isEmpty() ? "<noname>" :23 w->objectName().toUtf8().constData());24 return QString(QLatin1String("<no-widget>"));25 }26 27 #endif28 29 5 #define myDefFlagEx(var,fl,varstr,flstr) if (var & fl) { \ 30 if (!varstr.isEmpty()) varstr += QLatin1String("|"); varstr += QLatin1String(flstr); \6 if (!varstr.isEmpty()) varstr += ; \ 31 7 } else do {} while(0) 32 8 … … 38 14 QDebug operator<<(QDebug dbg, Qt::WindowStates st) 39 15 { 40 Q Stringname;16 Q name; 41 17 myDefFlagEx(st, Qt::WindowMinimized, name, "Min"); 42 18 myDefFlagEx(st, Qt::WindowMaximized, name, "Max"); 43 19 myDefFlagEx(st, Qt::WindowFullScreen, name, "Full"); 44 20 myDefFlagEx(st, Qt::WindowActive, name, "Act"); 45 if (name.isEmpty()) name = QLatin1String("None");46 dbg.nospace() << "WindowState(" << QDbgStr(name) << ")";21 if (name.isEmpty()) name = ; 22 dbg.nospace() << "WindowState(" << ) << ")"; 47 23 return dbg.space(); 48 24 } … … 50 26 QDebug operator<<(QDebug dbg, Qt::FocusReason r) 51 27 { 52 Q Stringname;28 Q name; 53 29 if (r == Qt::MouseFocusReason) name = "Mouse"; 54 30 if (r == Qt::TabFocusReason) name = "Tab"; … … 59 35 if (r == Qt::MenuBarFocusReason) name = "MenuBar"; 60 36 if (r == Qt::OtherFocusReason) name = "Other"; 61 dbg.nospace() << "FocusReason(" << QDbgStr(name) << ")";37 dbg.nospace() << "FocusReason(" << ) << ")"; 62 38 return dbg.space(); 63 39 } … … 80 56 void paintEvent(QPaintEvent *aE) 81 57 { 82 qDebug() << qWidgetName(this)<< __FUNCTION__58 qDebug() << << __FUNCTION__ 83 59 << ": " << aE->rect() << "focus" << hasFocus(); 84 60 … … 108 84 void focusInEvent(QFocusEvent *aE) 109 85 { 110 qDebug() << qWidgetName(this)<< __FUNCTION__ << ": reason" << aE->reason();86 qDebug() << << __FUNCTION__ << ": reason" << aE->reason(); 111 87 QWidget::focusInEvent(aE); 112 88 } … … 114 90 void focusOutEvent(QFocusEvent *aE) 115 91 { 116 qDebug() << qWidgetName(this)<< __FUNCTION__ << ": reason" << aE->reason();92 qDebug() << << __FUNCTION__ << ": reason" << aE->reason(); 117 93 QWidget::focusOutEvent(aE); 118 94 } … … 140 116 void focusInEvent(QFocusEvent *aE) 141 117 { 142 qDebug() << qWidgetName(this)<< __FUNCTION__ << ":" << text()118 qDebug() << << __FUNCTION__ << ":" << text() 143 119 << "reason" << aE->reason() 144 << "focus" << (qApp->focusWidget() ? 145 qWidgetName(qApp->focusWidget()) : QDbgStr(QLatin1String("<none>"))); 120 << "focus" << qApp->focusWidget(); 146 121 147 122 QPushButton::focusInEvent(aE); … … 150 125 void focusOutEvent(QFocusEvent *aE) 151 126 { 152 qDebug() << qWidgetName(this)<< __FUNCTION__ << ":" << text()127 qDebug() << << __FUNCTION__ << ":" << text() 153 128 << "reason" << aE->reason() 154 << "focus" << (qApp->focusWidget() ? 155 qWidgetName(qApp->focusWidget()) : QDbgStr(QLatin1String("<none>"))); 129 << "focus" << qApp->focusWidget(); 156 130 QPushButton::focusOutEvent(aE); 157 131 } … … 171 145 void focusInEvent(QFocusEvent *aE) 172 146 { 173 qDebug() << qWidgetName(this)<< __FUNCTION__ << ":" << currentText()147 qDebug() << << __FUNCTION__ << ":" << currentText() 174 148 << "reason" << aE->reason() 175 << "focus" << (qApp->focusWidget() ? 176 qWidgetName(qApp->focusWidget()) : QDbgStr(QLatin1String("<none>"))); 149 << "focus" << qApp->focusWidget(); 177 150 QComboBox::focusInEvent(aE); 178 151 } … … 180 153 void focusOutEvent(QFocusEvent *aE) 181 154 { 182 qDebug() << qWidgetName(this)<< __FUNCTION__ << ":" << currentText()155 qDebug() << << __FUNCTION__ << ":" << currentText() 183 156 << "reason" << aE->reason() 184 << "focus" << (qApp->focusWidget() ? 185 qWidgetName(qApp->focusWidget()) : QDbgStr(QLatin1String("<none>"))); 157 << "focus" << qApp->focusWidget(); 186 158 QComboBox::focusOutEvent(aE); 187 159 } … … 218 190 { 219 191 qDebug() << __FUNCTION__ << ": btn" << aE->button() 220 << QDbgStr(QString().sprintf("btns %08X mods %08X",221 (int) aE->buttons(), (int) aE->modifiers()))192 << 193 )) 222 194 << "gpos" << aE->globalPos() << "pos" << aE->pos(); 223 195 QComboBox::mousePressEvent(aE); … … 227 199 { 228 200 qDebug() << __FUNCTION__ << ": btn" << aE->button() 229 << QDbgStr(QString().sprintf("btns %08X mods %08X",230 (int) aE->buttons(), (int) aE->modifiers()))201 << 202 )) 231 203 << "gpos" << aE->globalPos() << "pos" << aE->pos(); 232 204 QComboBox::mouseReleaseEvent(aE); … … 371 343 void focusInEvent(QFocusEvent *aE) 372 344 { 373 qDebug() << qWidgetName(this)<< __FUNCTION__ << ": reason" << aE->reason();345 qDebug() << << __FUNCTION__ << ": reason" << aE->reason(); 374 346 QWidget::focusInEvent(aE); 375 347 } … … 377 349 void focusOutEvent(QFocusEvent *aE) 378 350 { 379 qDebug() << qWidgetName(this)<< __FUNCTION__ << ": reason" << aE->reason();351 qDebug() << << __FUNCTION__ << ": reason" << aE->reason(); 380 352 QWidget::focusOutEvent(aE); 381 353 } … … 401 373 void keyPressEvent(QKeyEvent *aE) 402 374 { 403 qDebug() << __FUNCTION__ << " : cnt" << aE->count()404 << "rep" << aE->isAutoRepeat()405 << QDbgStr(QString().sprintf("key %08X mods %08X", aE->key(), (int) aE->modifiers()))406 << "text" << aE->text()407 << QDbgStr(aE->text().isEmpty() ? QString() :408 QString().sprintf("(%04X)", aE->text()[0].unicode()));409 }410 411 void keyReleaseEvent(QKeyEvent *aE)412 {413 375 qDebug() << __FUNCTION__ << ": cnt" << aE->count() 414 376 << "rep" << aE->isAutoRepeat() 415 << QDbgStr(QString().sprintf("key %08X mods %08X", aE->key(), (int) aE->modifiers())) 377 << "key" << qDebugFmtHex(aE->key()) 378 << "mods" << qDebugFmtHex(aE->modifiers()) 416 379 << "text" << aE->text() 417 << QDbgStr(aE->text().isEmpty() ? QString() : 418 QString().sprintf("(%04X)", aE->text()[0].unicode())); 380 << qDebugFmtHex((aE->text().isEmpty() ? 0 : 381 aE->text()[0].unicode())); 382 } 383 384 void keyReleaseEvent(QKeyEvent *aE) 385 { 386 qDebug() << __FUNCTION__ << ": cnt" << aE->count() 387 << "rep" << aE->isAutoRepeat() 388 << "key" << qDebugFmtHex(aE->key()) 389 << "mods" << qDebugFmtHex(aE->modifiers()) 390 << "text" << aE->text() 391 << qDebugFmtHex((aE->text().isEmpty() ? 0 : 392 aE->text()[0].unicode())); 419 393 } 420 394 #endif … … 438 412 { 439 413 qDebug() << __FUNCTION__ << ": btn" << aE->button() 440 << QDbgStr(QString().sprintf("btns %08X mods %08X",441 (int) aE->buttons(), (int) aE->modifiers()))414 << 415 )) 442 416 << "gpos" << aE->globalPos() << "pos" << aE->pos(); 443 417 … … 449 423 { 450 424 qDebug() << __FUNCTION__ << ": btn" << aE->button() 451 << QDbgStr(QString().sprintf("btns %08X mods %08X",452 (int) aE->buttons(), (int) aE->modifiers()))425 << 426 )) 453 427 << "gpos" << aE->globalPos() << "pos" << aE->pos(); 454 428 } … … 457 431 { 458 432 qDebug() << __FUNCTION__ << ": btn" << aE->button() 459 << QDbgStr(QString().sprintf("btns %08X mods %08X",460 (int) aE->buttons(), (int) aE->modifiers()))433 << 434 )) 461 435 << "gpos" << aE->globalPos() << "pos" << aE->pos(); 462 436 } … … 509 483 QMouseEvent *me = static_cast<QMouseEvent*>(aE); 510 484 qDebug() << this << aE->type() << ": btn" << me->button() 511 << QDbgStr(QString().sprintf("btns %08X mods %08X",512 (int) me->buttons(), (int) me->modifiers()))485 << 486 )) 513 487 << "gpos" << me->globalPos() << "pos" << me->pos(); 514 488 break; … … 568 542 569 543 #if 1 544 545 546 547 548 549 550 551 552 553 554 555 570 556 //-------------------------------------------------------------------------- 571 557 // QFileInfo test
Note:
See TracChangeset
for help on using the changeset viewer.