1 | #include <QDebug>
|
---|
2 |
|
---|
3 | #include <QtGui>
|
---|
4 |
|
---|
5 | #ifndef Q_WS_PM
|
---|
6 |
|
---|
7 | // For printing non-quoted QString's with QDebug)
|
---|
8 | struct QDbgStr: public QString
|
---|
9 | {
|
---|
10 | inline QDbgStr(const QString &str) : QString(str) {}
|
---|
11 | };
|
---|
12 |
|
---|
13 | // Prints a non-quoted QString
|
---|
14 | 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 | #endif
|
---|
28 |
|
---|
29 | #define myDefFlagEx(var,fl,varstr,flstr) if (var & fl) { \
|
---|
30 | if (!varstr.isEmpty()) varstr += QLatin1String("|"); varstr += QLatin1String(flstr); \
|
---|
31 | } else do {} while(0)
|
---|
32 |
|
---|
33 | #define myDefFlag(var,fl,varstr) myDefFlagEx(var,fl,varstr,#fl)
|
---|
34 | #define myDefFlagCut(var,fl,varstr,pos) myDefFlagEx(var,fl,varstr,#fl + pos)
|
---|
35 |
|
---|
36 | #define PRINT_EXPR(e) qWarning() << #e << e
|
---|
37 |
|
---|
38 | QDebug operator<<(QDebug dbg, Qt::WindowStates st)
|
---|
39 | {
|
---|
40 | QString name;
|
---|
41 | myDefFlagEx(st, Qt::WindowMinimized, name, "Min");
|
---|
42 | myDefFlagEx(st, Qt::WindowMaximized, name, "Max");
|
---|
43 | myDefFlagEx(st, Qt::WindowFullScreen, name, "Full");
|
---|
44 | myDefFlagEx(st, Qt::WindowActive, name, "Act");
|
---|
45 | if (name.isEmpty()) name = QLatin1String("None");
|
---|
46 | dbg.nospace() << "WindowState(" << QDbgStr(name) << ")";
|
---|
47 | return dbg.space();
|
---|
48 | }
|
---|
49 |
|
---|
50 | QDebug operator<<(QDebug dbg, Qt::FocusReason r)
|
---|
51 | {
|
---|
52 | QString name;
|
---|
53 | if (r == Qt::MouseFocusReason) name = "Mouse";
|
---|
54 | if (r == Qt::TabFocusReason) name = "Tab";
|
---|
55 | if (r == Qt::BacktabFocusReason) name = "Backtab";
|
---|
56 | if (r == Qt::ActiveWindowFocusReason) name = "ActWin";
|
---|
57 | if (r == Qt::PopupFocusReason) name = "Popup";
|
---|
58 | if (r == Qt::ShortcutFocusReason) name = "Shortcut";
|
---|
59 | if (r == Qt::MenuBarFocusReason) name = "MenuBar";
|
---|
60 | if (r == Qt::OtherFocusReason) name = "Other";
|
---|
61 | dbg.nospace() << "FocusReason(" << QDbgStr(name) << ")";
|
---|
62 | return dbg.space();
|
---|
63 | }
|
---|
64 |
|
---|
65 | ////////////////////////////////////////////////////////////////////////////////
|
---|
66 |
|
---|
67 | class MyChild : public QWidget
|
---|
68 | {
|
---|
69 | Q_OBJECT
|
---|
70 |
|
---|
71 | public:
|
---|
72 |
|
---|
73 | MyChild(QWidget *aParent) : QWidget(aParent), mPressed(0)
|
---|
|
---|