diff options
Diffstat (limited to 'tests')
41 files changed, 1085 insertions, 266 deletions
diff --git a/tests/arthur/data/1.2/textArea01.svg b/tests/arthur/data/1.2/textArea01.svg index 79fcd0a..945c34c 100644 --- a/tests/arthur/data/1.2/textArea01.svg +++ b/tests/arthur/data/1.2/textArea01.svg @@ -6,5 +6,5 @@ height="300">Tomorrow, and tomorrow, and tomorrow; creeps in this petty pace from day to day, until the last syll­able of recorded time. And all our yesterdays have lighted fools the way to dusty death.</textArea> - <rect x="5" y="5" width="210" height="310" stroke-width="3" stroke="#777"/> + <rect x="5" y="5" width="210" height="310" stroke-width="3" stroke="#777" fill="none"/> </svg> diff --git a/tests/arthur/data/qps/linear_gradients_perspectives_qps.png b/tests/arthur/data/qps/linear_gradients_perspectives_qps.png Binary files differindex 42ba872..3315ebe 100644 --- a/tests/arthur/data/qps/linear_gradients_perspectives_qps.png +++ b/tests/arthur/data/qps/linear_gradients_perspectives_qps.png diff --git a/tests/arthur/data/qps/linear_gradients_qps.png b/tests/arthur/data/qps/linear_gradients_qps.png Binary files differindex dc5223b..a4cdc43 100644 --- a/tests/arthur/data/qps/linear_gradients_qps.png +++ b/tests/arthur/data/qps/linear_gradients_qps.png diff --git a/tests/arthur/data/qps/lineconsistency_qps.png b/tests/arthur/data/qps/lineconsistency_qps.png Binary files differindex 48768ef..9d19a5d 100644 --- a/tests/arthur/data/qps/lineconsistency_qps.png +++ b/tests/arthur/data/qps/lineconsistency_qps.png diff --git a/tests/arthur/data/qps/linedashes2_aa_qps.png b/tests/arthur/data/qps/linedashes2_aa_qps.png Binary files differindex 0cb5b40..54c84b3 100644 --- a/tests/arthur/data/qps/linedashes2_aa_qps.png +++ b/tests/arthur/data/qps/linedashes2_aa_qps.png diff --git a/tests/arthur/data/qps/paths_aa_qps.png b/tests/arthur/data/qps/paths_aa_qps.png Binary files differindex 45b4b74..e51a4ac 100644 --- a/tests/arthur/data/qps/paths_aa_qps.png +++ b/tests/arthur/data/qps/paths_aa_qps.png diff --git a/tests/arthur/data/qps/paths_qps.png b/tests/arthur/data/qps/paths_qps.png Binary files differindex a9a8743..094a84f 100644 --- a/tests/arthur/data/qps/paths_qps.png +++ b/tests/arthur/data/qps/paths_qps.png diff --git a/tests/arthur/data/qps/radial_gradients_perspectives_qps.png b/tests/arthur/data/qps/radial_gradients_perspectives_qps.png Binary files differindex 0e28aae..d833250 100644 --- a/tests/arthur/data/qps/radial_gradients_perspectives_qps.png +++ b/tests/arthur/data/qps/radial_gradients_perspectives_qps.png diff --git a/tests/arthur/data/qps/radial_gradients_qps.png b/tests/arthur/data/qps/radial_gradients_qps.png Binary files differindex 66fcfc4..11043e8 100644 --- a/tests/arthur/data/qps/radial_gradients_qps.png +++ b/tests/arthur/data/qps/radial_gradients_qps.png diff --git a/tests/arthur/data/qps/rasterops.qps b/tests/arthur/data/qps/rasterops.qps index b79ec0d..ee3deca 100644 --- a/tests/arthur/data/qps/rasterops.qps +++ b/tests/arthur/data/qps/rasterops.qps @@ -1,83 +1,84 @@ -setPen NoPen - -setBrush black -drawRect 10 10 1200 140 - -setCompositionMode SourceOrDestination -translate 20 20 -begin_block drawShape -setBrush 0xffff0000 -drawEllipse 10 10 80 80 -setBrush 0xff00ff00 -drawRect 0 0 50 50 -setBrush 0xff0000ff -drawRect 50 50 50 50 -end_block - -begin_block loop -setCompositionMode SourceAndDestination -translate 120 0 -repeat_block drawShape - -setCompositionMode SourceXorDestination -translate 120 0 -repeat_block drawShape - -setCompositionMode NotSourceAndNotDestination -translate 120 0 -repeat_block drawShape - -setCompositionMode NotSourceOrNotDestination -translate 120 0 -repeat_block drawShape - -setCompositionMode NotSourceXorDestination -translate 120 0 -repeat_block drawShape - -setCompositionMode NotSource -translate 120 0 -repeat_block drawShape - -setCompositionMode NotSourceAndDestination -translate 120 0 -repeat_block drawShape - -setCompositionMode SourceAndNotDestination -translate 120 0 -repeat_block drawShape -end_block - -resetMatrix -setCompositionMode Source -setBrush white -drawRect 10 160 1200 140 -translate 20 170 -repeat_block loop - -resetMatrix -setCompositionMode Source -translate 20 320 -repeat_block loop - -resetMatrix -setPen black -setCompositionMode SourceOver -translate 20 470 -drawText 20 0 "Or ROP" -translate 120 0 -drawText 20 0 "And ROP" -translate 120 0 -drawText 20 0 "Xor ROP" -translate 120 0 -drawText 20 0 "Nor ROP" -translate 120 0 -drawText 20 0 "Nand ROP" -translate 120 0 -drawText 0 0 "NSrcXorDst ROP" -translate 120 0 -drawText 20 0 "NSrc ROP" -translate 120 0 -drawText 0 0 "NSrcAndDst ROP" -translate 120 0 -drawText 0 0 "SrcAndNDst ROP" +setPen NoPen
+
+setBrush black
+drawRect 10 10 60 500
+
+setCompositionMode SourceOrDestination
+translate 20 20
+
+begin_block drawShape
+ setBrush 0xffff0000
+ drawEllipse 5 5 30 30
+ setBrush 0xff00ff00
+ drawRect 0 0 20 20
+ setBrush 0xff0000ff
+ drawRect 20 20 20 20
+end_block
+
+begin_block loop
+ setCompositionMode SourceAndDestination
+ translate 0 50
+repeat_block drawShape
+
+setCompositionMode SourceXorDestination
+translate 0 50
+repeat_block drawShape
+
+setCompositionMode NotSourceAndNotDestination
+translate 0 50
+repeat_block drawShape
+
+setCompositionMode NotSourceOrNotDestination
+translate 0 50
+repeat_block drawShape
+
+setCompositionMode NotSourceXorDestination
+translate 0 50
+repeat_block drawShape
+
+setCompositionMode NotSource
+translate 0 50
+repeat_block drawShape
+
+setCompositionMode NotSourceAndDestination
+translate 0 50
+repeat_block drawShape
+
+setCompositionMode SourceAndNotDestination
+translate 0 50
+repeat_block drawShape
+end_block
+
+resetMatrix
+setCompositionMode Source
+setBrush white
+drawRect 100 10 60 500
+translate 110 20
+repeat_block loop
+
+resetMatrix
+setCompositionMode Source
+translate 190 20
+repeat_block loop
+
+resetMatrix
+setPen black
+setCompositionMode SourceOver
+translate 250 45
+drawText 20 0 "Or ROP"
+translate 0 50
+drawText 20 0 "And ROP"
+translate 0 50
+drawText 20 0 "Xor ROP"
+translate 0 50
+drawText 20 0 "Nor ROP"
+translate 0 50
+drawText 20 0 "Nand ROP"
+translate 0 50
+drawText 0 0 "NSrcXorDst ROP"
+translate 0 50
+drawText 20 0 "NSrc ROP"
+translate 0 50
+drawText 0 0 "NSrcAndDst ROP"
+translate 0 50
+drawText 0 0 "SrcAndNDst ROP"
diff --git a/tests/arthur/data/qps/rasterops_qps.png b/tests/arthur/data/qps/rasterops_qps.png Binary files differindex 80ca8ae..7b93001 100644 --- a/tests/arthur/data/qps/rasterops_qps.png +++ b/tests/arthur/data/qps/rasterops_qps.png diff --git a/tests/arthur/data/qps/text_perspectives_qps.png b/tests/arthur/data/qps/text_perspectives_qps.png Binary files differindex 483ccc0..183ad6f 100644 --- a/tests/arthur/data/qps/text_perspectives_qps.png +++ b/tests/arthur/data/qps/text_perspectives_qps.png diff --git a/tests/arthur/data/qps/text_qps.png b/tests/arthur/data/qps/text_qps.png Binary files differindex 2c2ebf2..9a95493 100644 --- a/tests/arthur/data/qps/text_qps.png +++ b/tests/arthur/data/qps/text_qps.png diff --git a/tests/arthur/lance/interactivewidget.cpp b/tests/arthur/lance/interactivewidget.cpp index 0febbed..0c2c7a6 100644 --- a/tests/arthur/lance/interactivewidget.cpp +++ b/tests/arthur/lance/interactivewidget.cpp @@ -43,7 +43,7 @@ InteractiveWidget::InteractiveWidget() { - m_onScreenWidget = new OnScreenWidget<QWidget>(); + m_onScreenWidget = new OnScreenWidget<QWidget>(""); m_onScreenWidget->setMinimumSize(320, 240); setCentralWidget(m_onScreenWidget); diff --git a/tests/arthur/lance/lance.pro b/tests/arthur/lance/lance.pro index 193dbd2..ee9e08b 100644 --- a/tests/arthur/lance/lance.pro +++ b/tests/arthur/lance/lance.pro @@ -6,7 +6,7 @@ INCLUDEPATH += . # Input HEADERS += widgets.h interactivewidget.h -SOURCES += interactivewidget.cpp main.cpp +SOURCES += interactivewidget.cpp main.cpp RESOURCES += icons.qrc contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2):QT += opengl diff --git a/tests/arthur/lance/main.cpp b/tests/arthur/lance/main.cpp index 07e5180..f95b426 100644 --- a/tests/arthur/lance/main.cpp +++ b/tests/arthur/lance/main.cpp @@ -66,7 +66,7 @@ extern bool qt_show_painter_debug_output = false; //#define CONSOLE_APPLICATION -static const struct { +static const struct { const char *name; QImage::Format format; } imageFormats[] = { @@ -282,7 +282,7 @@ int main(int argc, char **argv) if (imageFormat == QImage::Format_Invalid) { printf("Invalid image format. Available formats are:\n"); - for (int ff = 0; ff < formatCount; ++ff) + for (int ff = 0; ff < formatCount; ++ff) printf("\t%s\n", imageFormats[ff].name); return -1; } @@ -403,12 +403,10 @@ int main(int argc, char **argv) case WidgetType: { OnScreenWidget<QWidget> *qWidget = - new OnScreenWidget<QWidget>; + new OnScreenWidget<QWidget>(files.at(j)); qWidget->setVerboseMode(verboseMode); qWidget->setType(type); qWidget->setCheckersBackground(checkers_background); - qWidget->m_filename = files.at(j); - qWidget->setWindowTitle(fileinfo.filePath()); qWidget->m_commands = content; qWidget->resize(width, height); qWidget->show(); @@ -418,12 +416,10 @@ int main(int argc, char **argv) case ImageWidgetType: { - OnScreenWidget<QWidget> *qWidget = new OnScreenWidget<QWidget>; + OnScreenWidget<QWidget> *qWidget = new OnScreenWidget<QWidget>(files.at(j)); qWidget->setVerboseMode(verboseMode); qWidget->setType(type); qWidget->setCheckersBackground(checkers_background); - qWidget->m_filename = files.at(j); - qWidget->setWindowTitle(fileinfo.filePath()); qWidget->m_commands = content; qWidget->resize(width, height); qWidget->show(); @@ -452,12 +448,10 @@ int main(int argc, char **argv) } case OpenGLType: { - OnScreenWidget<QGLWidget> *qGLWidget = new OnScreenWidget<QGLWidget>; + OnScreenWidget<QGLWidget> *qGLWidget = new OnScreenWidget<QGLWidget>(files.at(j)); qGLWidget->setVerboseMode(verboseMode); qGLWidget->setType(type); qGLWidget->setCheckersBackground(checkers_background); - qGLWidget->m_filename = files.at(j); - qGLWidget->setWindowTitle(fileinfo.filePath()); qGLWidget->m_commands = content; qGLWidget->resize(width, height); qGLWidget->show(); diff --git a/tests/arthur/lance/widgets.h b/tests/arthur/lance/widgets.h index 271c18a..7247608 100644 --- a/tests/arthur/lance/widgets.h +++ b/tests/arthur/lance/widgets.h @@ -57,15 +57,47 @@ #include <QTextStream> #include <QPaintEngine> +#include <private/qwindowsurface_p.h> + #include <qmath.h> const int CP_RADIUS = 10; +class StupidWorkaround : public QObject +{ + Q_OBJECT +public: + StupidWorkaround(QWidget *widget, int *value) + : QObject(widget), w(widget), mode(value) + { + } + +public slots: + void setViewMode(int m) { + *mode = m; + w->update(); + } + +private: + QWidget *w; + int *mode; +}; + template <class T> class OnScreenWidget : public T { public: - OnScreenWidget(QWidget *parent = 0) : T(parent) + + enum ViewMode { + RenderView, + BaselineView, + DifferenceView + }; + + OnScreenWidget(const QString &file, QWidget *parent = 0) + : T(parent), + m_view_mode(RenderView), + m_filename(file) { QSettings settings("Trolltech", "lance"); for (int i=0; i<10; ++i) { @@ -78,11 +110,47 @@ public: m_deviceType = WidgetType; m_checkersBackground = true; m_verboseMode = false; - } - void setVerboseMode(bool v) { m_verboseMode = v; } - void setCheckersBackground(bool b) { m_checkersBackground = b; } - void setType(DeviceType t) { m_deviceType = t; } + m_baseline_name = QString(m_filename).replace(".qps", "_qps") + ".png"; + if (QFileInfo(m_baseline_name).exists()) { + m_baseline = QPixmap(m_baseline_name); + } + + if (m_baseline.isNull()) { + setWindowTitle("Rendering: '" + file + "'. No baseline available"); + } else { + setWindowTitle("Rendering: '" + file + "'. Shortcuts: 1=render, 2=baseline, 3=difference"); + + StupidWorkaround *workaround = new StupidWorkaround(this, &m_view_mode); + + QSignalMapper *mapper = new QSignalMapper(this); + connect(mapper, SIGNAL(mapped(int)), workaround, SLOT(setViewMode(int))); + connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setWindowTitle(QString))); + + QAction *renderViewAction = new QAction("Render View", this); + renderViewAction->setShortcut(Qt::Key_1); + connect(renderViewAction, SIGNAL(triggered()), mapper, SLOT(map())); + mapper->setMapping(renderViewAction, RenderView); + mapper->setMapping(renderViewAction, "Render View: " + file); + addAction(renderViewAction); + + QAction *baselineAction = new QAction("Baseline", this); + baselineAction->setShortcut(Qt::Key_2); + connect(baselineAction, SIGNAL(triggered()), mapper, SLOT(map())); + mapper->setMapping(baselineAction, BaselineView); + mapper->setMapping(baselineAction, "Baseline View: " + file); + addAction(baselineAction); + + QAction *differenceAction = new QAction("Differenfe View", this); + differenceAction->setShortcut(Qt::Key_3); + connect(differenceAction, SIGNAL(triggered()), mapper, SLOT(map())); + mapper->setMapping(differenceAction, DifferenceView); + mapper->setMapping(differenceAction, "Difference View" + file); + addAction(differenceAction); + + } + + } ~OnScreenWidget() { @@ -93,12 +161,24 @@ public: settings.sync(); } + void setVerboseMode(bool v) { m_verboseMode = v; } + void setCheckersBackground(bool b) { m_checkersBackground = b; } + void setType(DeviceType t) { m_deviceType = t; } + void resizeEvent(QResizeEvent *e) { m_image = QImage(); T::resizeEvent(e); } - void paintEvent(QPaintEvent *) + void paintEvent(QPaintEvent *) { + switch (m_view_mode) { + case RenderView: paintRenderView(); break; + case BaselineView: paintBaselineView(); break; + case DifferenceView: paintDifferenceView(); break; + } + } + + void OnScreenWidget<T>::paintRenderView() { QPainter pt; QPaintDevice *dev = this; @@ -152,6 +232,57 @@ public: } } + if (m_render_view.isNull()) { + m_render_view = window()->windowSurface()->grabWidget(this); + m_render_view.save("renderView.png"); + } + } + + void paintBaselineView() { + QPainter p(this); + + if (m_baseline.isNull()) { + p.drawText(rect(), Qt::AlignCenter, + "No baseline found\n" + "file '" + m_baseline_name + "' does not exist..."); + return; + } + + p.drawPixmap(0, 0, m_baseline); + + p.setPen(QColor::fromRgb(0, 0, 0, 0.1)); + p.setFont(QFont("Arial", 128)); + p.rotate(45); + p.drawText(100, 0, "BASELINE"); + } + + QPixmap generateDifference() + { + QImage img(size(), QImage::Format_RGB32); + img.fill(0); + + QPainter p(&img); + p.drawPixmap(0, 0, m_render_view); + + p.setCompositionMode(QPainter::RasterOp_SourceXorDestination); + p.drawPixmap(0, 0, m_baseline); + + p.end(); + + return QPixmap::fromImage(img); + } + + void paintDifferenceView() { + QPainter p(this); + if (m_baseline.isNull()) { + p.drawText(rect(), Qt::AlignCenter, + "No baseline found\n" + "file '" + m_baseline_name + "' does not exist..."); + return; + } + + p.fillRect(rect(), Qt::black); + p.drawPixmap(0, 0, generateDifference()); } @@ -190,8 +321,6 @@ public: T::update(); } - - QSize sizeHint() const { return QSize(800, 800); } QVector<QPointF> m_controlPoints; @@ -200,12 +329,18 @@ public: QStringList m_commands; QString m_filename; + QString m_baseline_name; bool m_verboseMode; bool m_checkersBackground; DeviceType m_deviceType; + int m_view_mode; + QImage m_image; + + QPixmap m_baseline; + QPixmap m_render_view; }; #endif diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 6f10922..b4a6600 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -159,9 +159,9 @@ SUBDIRS += _networkselftest \ qhash \ qheaderview \ qhelpcontentmodel \ -# qhelpenginecore \ + qhelpenginecore \ qhelpgenerator \ -# qhelpindexmodel \ + qhelpindexmodel \ qhelpprojectdata \ qhostaddress \ qhostinfo \ diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp index d66791f..488f068 100644 --- a/tests/auto/moc/tst_moc.cpp +++ b/tests/auto/moc/tst_moc.cpp @@ -1157,6 +1157,13 @@ void tst_Moc::constructors() QObject *o3 = mo->newInstance(Q_ARG(QString, str)); QVERIFY(o3 != 0); QCOMPARE(qobject_cast<CtorTestClass*>(o3)->m_str, str); + + { + //explicit constructor + QObject *o = QObject::staticMetaObject.newInstance(); + QVERIFY(o); + delete o; + } } #include "task234909.h" diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index 0a9c16a..a65490d 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -138,6 +138,7 @@ private slots: void setters(); void dynamicSortOrder(); + void disabledItems(); // task-specific tests below me void task178797_activatedOnReturn(); @@ -147,7 +148,6 @@ private slots: void task253125_lineEditCompletion_data(); void task253125_lineEditCompletion(); - void task247560_keyboardNavigation(); private: @@ -1106,6 +1106,31 @@ void tst_QCompleter::dynamicSortOrder() QCOMPARE(completer.completionCount(), 12); } +void tst_QCompleter::disabledItems() +{ + QLineEdit lineEdit; + QStandardItemModel *model = new QStandardItemModel(&lineEdit); + QStandardItem *suggestions = new QStandardItem("suggestions"); + suggestions->setEnabled(false); + model->appendRow(suggestions); + model->appendRow(new QStandardItem("suggestions Enabled")); + QCompleter *completer = new QCompleter(model, &lineEdit); + QSignalSpy spy(completer, SIGNAL(activated(const QString &))); + lineEdit.setCompleter(completer); + lineEdit.show(); + + QTest::keyPress(&lineEdit, Qt::Key_S); + QTest::keyPress(&lineEdit, Qt::Key_U); + QAbstractItemView *view = lineEdit.completer()->popup(); + QVERIFY(view->isVisible()); + QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->visualRect(view->model()->index(0, 0)).center()); + QCOMPARE(spy.count(), 0); + QVERIFY(view->isVisible()); + QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->visualRect(view->model()->index(1, 0)).center()); + QCOMPARE(spy.count(), 1); + QVERIFY(!view->isVisible()); +} + void tst_QCompleter::task178797_activatedOnReturn() { QStringList words; diff --git a/tests/auto/qhelpenginecore/data/collection.qhc b/tests/auto/qhelpenginecore/data/collection.qhc Binary files differindex 6fb8abb..bd2f37c 100644 --- a/tests/auto/qhelpenginecore/data/collection.qhc +++ b/tests/auto/qhelpenginecore/data/collection.qhc diff --git a/tests/auto/qhelpenginecore/data/collection1.qhc b/tests/auto/qhelpenginecore/data/collection1.qhc Binary files differindex 45acf33..de310ea 100644 --- a/tests/auto/qhelpenginecore/data/collection1.qhc +++ b/tests/auto/qhelpenginecore/data/collection1.qhc diff --git a/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch b/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch Binary files differindex 0b53cd8..ed9a89c 100644 --- a/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch +++ b/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch diff --git a/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch b/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch Binary files differindex a3ca18a..0e95c14 100644 --- a/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch +++ b/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch diff --git a/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch b/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch Binary files differindex 8f76134..337d7a1 100644 --- a/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch +++ b/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch diff --git a/tests/auto/qhelpenginecore/data/test.qch b/tests/auto/qhelpenginecore/data/test.qch Binary files differindex 8a8f7a1..06b789a 100644 --- a/tests/auto/qhelpenginecore/data/test.qch +++ b/tests/auto/qhelpenginecore/data/test.qch diff --git a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp index d62c8e5..f9aa653 100644 --- a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp +++ b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp @@ -130,7 +130,7 @@ void tst_QHelpEngineCore::setCollectionFile() QStringList docs = help.registeredDocumentations(); QCOMPARE(docs.count(), 1); - QCOMPARE(docs.first(), QLatin1String("trolltech.com.1_0_0.test")); + QCOMPARE(docs.first(), QLatin1String("trolltech.com.1-0-0.test")); } void tst_QHelpEngineCore::copyCollectionFile() @@ -177,7 +177,7 @@ void tst_QHelpEngineCore::copyCollectionFile() i = 0; while (m_query->next()) { if (i == 0) { - QCOMPARE(m_query->value(0).toString(), QString("trolltech.com.3_3_8.qmake")); + QCOMPARE(m_query->value(0).toString(), QString("trolltech.com.3-3-8.qmake")); QCOMPARE(m_query->value(1).toString(), QString("data/qmake-3.3.8.qch")); } ++i; @@ -193,9 +193,9 @@ void tst_QHelpEngineCore::copyCollectionFile() void tst_QHelpEngineCore::namespaceName() { QCOMPARE(QHelpEngineCore::namespaceName(m_path + "/data/qmake-3.3.8.qch"), - QString("trolltech.com.3_3_8.qmake")); + QString("trolltech.com.3-3-8.qmake")); QCOMPARE(QHelpEngineCore::namespaceName(m_path + "/data/linguist-3.3.8.qch"), - QString("trolltech.com.3_3_8.linguist")); + QString("trolltech.com.3-3-8.linguist")); } void tst_QHelpEngineCore::registeredDocumentations() @@ -205,8 +205,8 @@ void tst_QHelpEngineCore::registeredDocumentations() QStringList docs = help.registeredDocumentations(); QCOMPARE(docs.count(), 3); QStringList lst; - lst << "trolltech.com.3_3_8.qmake" << "trolltech.com.4_3_0.qmake" - << "trolltech.com.1_0_0.test"; + lst << "trolltech.com.3-3-8.qmake" << "trolltech.com.4-3-0.qmake" + << "trolltech.com.1-0-0.test"; foreach (QString s, docs) lst.removeAll(s); QCOMPARE(lst.isEmpty(), true); @@ -236,7 +236,7 @@ void tst_QHelpEngineCore::registerDocumentation() } QSqlQuery query(db); query.exec("SELECT FilePath FROM NamespaceTable WHERE " - "Name=\'trolltech.com.3_3_8.linguist\'"); + "Name=\'trolltech.com.3-3-8.linguist\'"); if (query.next()) QCOMPARE(query.value(0).toString(), QString("linguist-3.3.8.qch")); @@ -251,7 +251,7 @@ void tst_QHelpEngineCore::unregisterDocumentation() QHelpEngineCore c(m_colFile); QCOMPARE(c.setupData(), true); QCOMPARE(c.registeredDocumentations().count(), 3); - c.unregisterDocumentation("trolltech.com.3_3_8.qmake"); + c.unregisterDocumentation("trolltech.com.3-3-8.qmake"); QCOMPARE(c.registeredDocumentations().count(), 2); QCOMPARE(c.unregisterDocumentation("noexisting"), false); } @@ -260,9 +260,9 @@ void tst_QHelpEngineCore::documentationFileName() { QHelpEngineCore c(m_colFile); QCOMPARE(c.setupData(), true); - QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.3_3_8.qmake")), + QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.3-3-8.qmake")), QString(m_path + "/data/qmake-3.3.8.qch")); - QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.1_0_0.test")), + QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.1-0-0.test")), QString(m_path + "/data/test.qch")); QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.empty")), QString()); @@ -337,7 +337,7 @@ void tst_QHelpEngineCore::filterAttributeSets() { QHelpEngineCore help(m_colFile, 0); QCOMPARE(help.setupData(), true); - QList<QStringList> lst = help.filterAttributeSets("trolltech.com.1_0_0.test"); + QList<QStringList> lst = help.filterAttributeSets("trolltech.com.1-0-0.test"); QCOMPARE(lst.count(), 2); QCOMPARE(lst.first().count(), 2); QCOMPARE((bool)lst.first().contains("filter1"), true); @@ -348,22 +348,22 @@ void tst_QHelpEngineCore::files() { QHelpEngineCore help(m_colFile, 0); QCOMPARE(help.setupData(), true); - QList<QUrl> lst = help.files("trolltech.com.4_3_0.qmake", + QList<QUrl> lst = help.files("trolltech.com.4-3-0.qmake", QStringList()); QCOMPARE(lst.count(), 16); - lst = help.files("trolltech.com.4_3_0.qmake", + lst = help.files("trolltech.com.4-3-0.qmake", QStringList(), "png"); QCOMPARE(lst.count(), 2); - lst = help.files("trolltech.com.4_3_0.qmake", + lst = help.files("trolltech.com.4-3-0.qmake", QStringList() << "qt", "html"); QCOMPARE(lst.count(), 13); - lst = help.files("trolltech.com.4_3_0.qmake", + lst = help.files("trolltech.com.4-3-0.qmake", QStringList() << "qt" << "qmake", "html"); QCOMPARE(lst.count(), 13); - lst = help.files("trolltech.com.4_3_0.qmake", + lst = help.files("trolltech.com.4-3-0.qmake", QStringList() << "qt" << "qmake" << "bla", "html"); QCOMPARE(lst.count(), 0); - lst = help.files("trolltech.com.4_3_0.qmake", + lst = help.files("trolltech.com.4-3-0.qmake", QStringList() << "qt" << "qmake", "foo"); QCOMPARE(lst.count(), 0); @@ -378,7 +378,7 @@ void tst_QHelpEngineCore::fileData() QCOMPARE(help.setupData(), true); QByteArray ba = help.fileData(QUrl("NotExisting")); QCOMPARE(ba.size(), 0); - ba = help.fileData(QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html")); + ba = help.fileData(QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html")); QTextStream s(ba, QIODevice::ReadOnly|QIODevice::Text); QFile f(m_path + "/data/test.html"); if (!f.open(QIODevice::ReadOnly|QIODevice::Text)) @@ -396,7 +396,7 @@ void tst_QHelpEngineCore::linksForIdentifier() QCOMPARE(map.contains("Test Manual"), true); QCOMPARE(map.count(), 1); QCOMPARE(map.value("Test Manual"), - QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html#foo")); + QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html#foo")); help.setCurrentFilter("Custom Filter 2"); map = help.linksForIdentifier("People::newton"); @@ -405,7 +405,7 @@ void tst_QHelpEngineCore::linksForIdentifier() QCOMPARE(map.contains("Fancy"), true); QCOMPARE(map.count(), 1); QCOMPARE(map.value("Fancy"), - QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/fancy.html#foobar")); + QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/fancy.html#foobar")); } void tst_QHelpEngineCore::customValue() diff --git a/tests/auto/qhelpindexmodel/data/collection.qhc b/tests/auto/qhelpindexmodel/data/collection.qhc Binary files differindex 6fb8abb..bd2f37c 100644 --- a/tests/auto/qhelpindexmodel/data/collection.qhc +++ b/tests/auto/qhelpindexmodel/data/collection.qhc diff --git a/tests/auto/qhelpindexmodel/data/collection1.qhc b/tests/auto/qhelpindexmodel/data/collection1.qhc Binary files differindex 45acf33..de310ea 100644 --- a/tests/auto/qhelpindexmodel/data/collection1.qhc +++ b/tests/auto/qhelpindexmodel/data/collection1.qhc diff --git a/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch b/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch Binary files differindex 0b53cd8..ed9a89c 100644 --- a/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch +++ b/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch diff --git a/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch b/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch Binary files differindex a3ca18a..0e95c14 100644 --- a/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch +++ b/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch diff --git a/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch b/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch Binary files differindex 8f76134..337d7a1 100644 --- a/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch +++ b/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch diff --git a/tests/auto/qhelpindexmodel/data/test.qch b/tests/auto/qhelpindexmodel/data/test.qch Binary files differindex 1d6c1a8..4ea9847 100644 --- a/tests/auto/qhelpindexmodel/data/test.qch +++ b/tests/auto/qhelpindexmodel/data/test.qch diff --git a/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp b/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp index 9482def..3adb894 100644 --- a/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp +++ b/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp @@ -185,11 +185,11 @@ void tst_QHelpIndexModel::linksForIndex() QCOMPARE(map.count(), 2); QCOMPARE(map.contains("Test Manual"), true); QCOMPARE(map.value("Test Manual"), - QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html#foo")); + QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html#foo")); QCOMPARE(map.contains("Fancy"), true); QCOMPARE(map.value("Fancy"), - QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/fancy.html#foo")); + QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/fancy.html#foo")); map = m->linksForKeyword("foobar"); QCOMPARE(map.count(), 1); @@ -208,7 +208,7 @@ void tst_QHelpIndexModel::linksForIndex() QCOMPARE(map.count(), 1); QCOMPARE(map.contains("Test Manual"), true); QCOMPARE(map.value("Test Manual"), - QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html#foo")); + QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html#foo")); } QTEST_MAIN(tst_QHelpIndexModel) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 03b1474..cfd3dd0 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -223,8 +223,10 @@ private Q_SLOTS: void rateControl(); void downloadPerformance(); void uploadPerformance(); - void httpUploadPerformance(); void performanceControlRate(); + void httpUploadPerformance(); + void httpDownloadPerformance_data(); + void httpDownloadPerformance(); void downloadProgress_data(); void downloadProgress(); @@ -248,8 +250,6 @@ private Q_SLOTS: void authorizationError(); void httpConnectionCount(); - void httpDownloadPerformance_data(); - void httpDownloadPerformance(); #ifndef QT_NO_OPENSSL void ignoreSslErrorsList_data(); @@ -513,10 +513,10 @@ public: QTcpSocket *active = new QTcpSocket(this); active->connectToHost("127.0.0.1", server.serverPort()); - if (!active->waitForConnected(10)) + if (!active->waitForConnected(100)) return false; - if (!server.waitForNewConnection(10)) + if (!server.waitForNewConnection(100)) return false; QTcpSocket *passive = server.nextPendingConnection(); passive->setParent(this); @@ -836,6 +836,92 @@ protected: } }; +class HttpDownloadPerformanceClient : QObject { + Q_OBJECT; + QIODevice *device; + public: + HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){ + connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); + } + + public slots: + void readyReadSlot() { + device->readAll(); + } + +}; + +class HttpDownloadPerformanceServer : QObject { + Q_OBJECT; + qint64 dataSize; + qint64 dataSent; + QTcpServer server; + QTcpSocket *client; + bool serverSendsContentLength; + bool chunkedEncoding; + +public: + HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0), + client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) { + server.listen(); + connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); + } + + int serverPort() { + return server.serverPort(); + } + +public slots: + + void newConnectionSlot() { + client = server.nextPendingConnection(); + client->setParent(this); + connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); + connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64))); + } + + void readyReadSlot() { + client->readAll(); + client->write("HTTP/1.0 200 OK\n"); + if (serverSendsContentLength) + client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii()); + if (chunkedEncoding) + client->write(QString("Transfer-Encoding: chunked\n").toAscii()); + client->write("Connection: close\n\n"); + } + + void bytesWrittenSlot(qint64 amount) { + Q_UNUSED(amount); + if (dataSent == dataSize && client) { + // close eventually + + // chunked encoding: we have to send a last "empty" chunk + if (chunkedEncoding) + client->write(QString("0\r\n\r\n").toAscii()); + + client->disconnectFromHost(); + server.close(); + client = 0; + return; + } + + // send data + if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) { + qint64 amount = qMin(qint64(16*1024), dataSize - dataSent); + QByteArray data(amount, '@'); + + if (chunkedEncoding) { + client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii()); + client->write(data.constData(), amount); + client->write(QString("\r\n").toAscii()); + } else { + client->write(data.constData(), amount); + } + + dataSent += amount; + } + } +}; tst_QNetworkReply::tst_QNetworkReply() @@ -2642,8 +2728,6 @@ void tst_QNetworkReply::ioPutToFileFromProcess() QCOMPARE(file.size(), qint64(data.size())); QByteArray contents = file.readAll(); QCOMPARE(contents, data); - - delete reply; #endif } @@ -3183,7 +3267,7 @@ void tst_QNetworkReply::uploadPerformance() void tst_QNetworkReply::httpUploadPerformance() { - enum {UploadSize = 1000*1024*1024}; // 1000 MB + enum {UploadSize = 128*1024*1024}; // 128 MB ThreadedDataReaderHttpServer reader; FixedSizeDataGenerator generator(UploadSize); @@ -3205,7 +3289,7 @@ void tst_QNetworkReply::httpUploadPerformance() << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; reader.exit(); - reader.wait(3000); + reader.wait(); } @@ -3233,6 +3317,41 @@ void tst_QNetworkReply::performanceControlRate() << elapsedTime << "ms"; } +void tst_QNetworkReply::httpDownloadPerformance_data() +{ + QTest::addColumn<bool>("serverSendsContentLength"); + QTest::addColumn<bool>("chunkedEncoding"); + + QTest::newRow("Server sends no Content-Length") << false << false; + QTest::newRow("Server sends Content-Length") << true << false; + QTest::newRow("Server uses chunked encoding") << false << true; + +} + +void tst_QNetworkReply::httpDownloadPerformance() +{ + QFETCH(bool, serverSendsContentLength); + QFETCH(bool, chunkedEncoding); + + enum {UploadSize = 128*1024*1024}; // 128 MB + HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); + + QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + HttpDownloadPerformanceClient client(reply); + + QTime time; + time.start(); + QTestEventLoop::instance().enterLoop(40); + QVERIFY(!QTestEventLoop::instance().timeout()); + + qint64 elapsed = time.elapsed(); + qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, " + << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; +} + void tst_QNetworkReply::downloadProgress_data() { QTest::addColumn<int>("loopCount"); @@ -3720,130 +3839,6 @@ void tst_QNetworkReply::httpConnectionCount() QCOMPARE(pendingConnectionCount, 6); } -class HttpDownloadPerformanceClient : QObject { - Q_OBJECT; - QIODevice *device; - public: - HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){ - connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); - } - - public slots: - void readyReadSlot() { - device->readAll(); - } - -}; - -class HttpDownloadPerformanceServer : QObject { - Q_OBJECT; - qint64 dataSize; - qint64 dataSent; - QTcpServer server; - QTcpSocket *client; - bool serverSendsContentLength; - bool chunkedEncoding; - -public: - HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0), - client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) { - server.listen(); - connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); - } - - int serverPort() { - return server.serverPort(); - } - -public slots: - - void newConnectionSlot() { - client = server.nextPendingConnection(); - client->setParent(this); - connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); - connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64))); - } - - void readyReadSlot() { - client->readAll(); - client->write("HTTP/1.0 200 OK\n"); - if (serverSendsContentLength) - client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii()); - if (chunkedEncoding) - client->write(QString("Transfer-Encoding: chunked\n").toAscii()); - client->write("Connection: close\n\n"); - } - - void bytesWrittenSlot(qint64 amount) { - Q_UNUSED(amount); - if (dataSent == dataSize && client) { - // close eventually - - // chunked encoding: we have to send a last "empty" chunk - if (chunkedEncoding) - client->write(QString("0\r\n\r\n").toAscii()); - - client->disconnectFromHost(); - server.close(); - client = 0; - return; - } - - // send data - if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) { - qint64 amount = qMin(qint64(16*1024), dataSize - dataSent); - QByteArray data(amount, '@'); - - if (chunkedEncoding) { - client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii()); - client->write(data.constData(), amount); - client->write(QString("\r\n").toAscii()); - } else { - client->write(data.constData(), amount); - } - - dataSent += amount; - } - } -}; - -void tst_QNetworkReply::httpDownloadPerformance_data() -{ - QTest::addColumn<bool>("serverSendsContentLength"); - QTest::addColumn<bool>("chunkedEncoding"); - - QTest::newRow("Server sends no Content-Length") << false << false; - QTest::newRow("Server sends Content-Length") << true << false; - QTest::newRow("Server uses chunked encoding") << false << true; - -} - -void tst_QNetworkReply::httpDownloadPerformance() -{ - QFETCH(bool, serverSendsContentLength); - QFETCH(bool, chunkedEncoding); - - enum {UploadSize = 1000*1024*1024}; // 1000 MB - HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); - - QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); - QNetworkReply* reply = manager.get(request); - - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - HttpDownloadPerformanceClient client(reply); - - QTime time; - time.start(); - QTestEventLoop::instance().enterLoop(40); - QVERIFY(!QTestEventLoop::instance().timeout()); - - qint64 elapsed = time.elapsed(); - qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, " - << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; - - delete reply; -} - #ifndef QT_NO_OPENSSL void tst_QNetworkReply::ignoreSslErrorsList_data() { @@ -3872,7 +3867,7 @@ void tst_QNetworkReply::ignoreSslErrorsList() { QFETCH(QString, url); QNetworkRequest request(url); - QNetworkReply *reply = manager.get(request); + QNetworkReplyPtr reply = manager.get(request); QFETCH(QList<QSslError>, expectedSslErrors); reply->ignoreSslErrors(expectedSslErrors); @@ -3901,7 +3896,7 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot() { QFETCH(QString, url); QNetworkRequest request(url); - QNetworkReply *reply = manager.get(request); + QNetworkReplyPtr reply = manager.get(request); QFETCH(QList<QSslError>, expectedSslErrors); // store the errors to ignore them later in the slot connected below diff --git a/tests/manual/windowflags/controllerwindow.cpp b/tests/manual/windowflags/controllerwindow.cpp new file mode 100644 index 0000000..055ff40 --- /dev/null +++ b/tests/manual/windowflags/controllerwindow.cpp @@ -0,0 +1,263 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +#include "controllerwindow.h" + +//! [0] +ControllerWindow::ControllerWindow() +{ + parentWindow = new QMainWindow; + parentWindow->setWindowTitle(tr("Preview parent window")); + QLabel *label = new QLabel(tr("Parent window")); + parentWindow->setCentralWidget(label); + + previewWindow = new PreviewWindow; + previewDialog = new PreviewDialog; + + createTypeGroupBox(); + createHintsGroupBox(); + + quitButton = new QPushButton(tr("&Quit")); + connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addStretch(); + bottomLayout->addWidget(quitButton); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(widgetTypeGroupBox); + mainLayout->addWidget(additionalOptionsGroupBox); + mainLayout->addWidget(typeGroupBox); + mainLayout->addWidget(hintsGroupBox); + mainLayout->addLayout(bottomLayout); + setLayout(mainLayout); + + setWindowTitle(tr("Window Flags")); + updatePreview(); +} + +void ControllerWindow::updatePreview() +{ + Qt::WindowFlags flags = 0; + + if (windowRadioButton->isChecked()) { + flags = Qt::Window; + } else if (dialogRadioButton->isChecked()) { + flags = Qt::Dialog; + } else if (sheetRadioButton->isChecked()) { + flags = Qt::Sheet; + } else if (drawerRadioButton->isChecked()) { + flags = Qt::Drawer; + } else if (popupRadioButton->isChecked()) { + flags = Qt::Popup; + } else if (toolRadioButton->isChecked()) { + flags = Qt::Tool; + } else if (toolTipRadioButton->isChecked()) { + flags = Qt::ToolTip; + } else if (splashScreenRadioButton->isChecked()) { + flags = Qt::SplashScreen; + } + + if (msWindowsFixedSizeDialogCheckBox->isChecked()) + flags |= Qt::MSWindowsFixedSizeDialogHint; + if (x11BypassWindowManagerCheckBox->isChecked()) + flags |= Qt::X11BypassWindowManagerHint; + if (framelessWindowCheckBox->isChecked()) + flags |= Qt::FramelessWindowHint; + if (windowTitleCheckBox->isChecked()) + flags |= Qt::WindowTitleHint; + if (windowSystemMenuCheckBox->isChecked()) + flags |= Qt::WindowSystemMenuHint; + if (windowMinimizeButtonCheckBox->isChecked()) + flags |= Qt::WindowMinimizeButtonHint; + if (windowMaximizeButtonCheckBox->isChecked()) + flags |= Qt::WindowMaximizeButtonHint; + if (windowCloseButtonCheckBox->isChecked()) + flags |= Qt::WindowCloseButtonHint; + if (windowContextHelpButtonCheckBox->isChecked()) + flags |= Qt::WindowContextHelpButtonHint; + if (windowShadeButtonCheckBox->isChecked()) + flags |= Qt::WindowShadeButtonHint; + if (windowStaysOnTopCheckBox->isChecked()) + flags |= Qt::WindowStaysOnTopHint; + if (windowStaysOnBottomCheckBox->isChecked()) + flags |= Qt::WindowStaysOnBottomHint; + if (customizeWindowHintCheckBox->isChecked()) + flags |= Qt::CustomizeWindowHint; + + previewWindow->hide(); + previewDialog->hide(); + QWidget *widget = 0; + if (previewWidgetButton->isChecked()) + widget = previewWindow; + else + widget = previewDialog; + + if (modalWindowCheckBox->isChecked()) { + parentWindow->show(); + widget->setWindowModality(Qt::WindowModal); + widget->setParent(parentWindow); + } else { + widget->setWindowModality(Qt::NonModal); + widget->setParent(0); + parentWindow->hide(); + } + + widget->setWindowFlags(flags); + + if (fixedSizeWindowCheckBox->isChecked()) { + widget->setFixedSize(300, 300); + } else { + widget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); + } + + QPoint pos = widget->pos(); + if (pos.x() < 0) + pos.setX(0); + if (pos.y() < 0) + pos.setY(0); + widget->move(pos); + widget->show(); +} + +void ControllerWindow::createTypeGroupBox() +{ + widgetTypeGroupBox = new QGroupBox(tr("Widget Type")); + previewWidgetButton = createRadioButton(tr("QWidget")); + previewWidgetButton->setChecked(true); + previewDialogButton = createRadioButton(tr("QDialog")); + QHBoxLayout *l = new QHBoxLayout; + l->addWidget(previewWidgetButton); + l->addWidget(previewDialogButton); + widgetTypeGroupBox->setLayout(l); + + additionalOptionsGroupBox = new QGroupBox(tr("Additional options")); + l = new QHBoxLayout; + modalWindowCheckBox = createCheckBox(tr("Modal window")); + fixedSizeWindowCheckBox = createCheckBox(tr("Fixed size window")); + l->addWidget(modalWindowCheckBox); + l->addWidget(fixedSizeWindowCheckBox); + additionalOptionsGroupBox->setLayout(l); + + typeGroupBox = new QGroupBox(tr("Type")); + + windowRadioButton = createRadioButton(tr("Window")); + dialogRadioButton = createRadioButton(tr("Dialog")); + sheetRadioButton = createRadioButton(tr("Sheet")); + drawerRadioButton = createRadioButton(tr("Drawer")); + popupRadioButton = createRadioButton(tr("Popup")); + toolRadioButton = createRadioButton(tr("Tool")); + toolTipRadioButton = createRadioButton(tr("Tooltip")); + splashScreenRadioButton = createRadioButton(tr("Splash screen")); + windowRadioButton->setChecked(true); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(windowRadioButton, 0, 0); + layout->addWidget(dialogRadioButton, 1, 0); + layout->addWidget(sheetRadioButton, 2, 0); + layout->addWidget(drawerRadioButton, 3, 0); + layout->addWidget(popupRadioButton, 0, 1); + layout->addWidget(toolRadioButton, 1, 1); + layout->addWidget(toolTipRadioButton, 2, 1); + layout->addWidget(splashScreenRadioButton, 3, 1); + typeGroupBox->setLayout(layout); +} +//! [5] + +//! [6] +void ControllerWindow::createHintsGroupBox() +{ + hintsGroupBox = new QGroupBox(tr("Hints")); + + msWindowsFixedSizeDialogCheckBox = + createCheckBox(tr("MS Windows fixed size dialog")); + x11BypassWindowManagerCheckBox = + createCheckBox(tr("X11 bypass window manager")); + framelessWindowCheckBox = createCheckBox(tr("Frameless window")); + windowTitleCheckBox = createCheckBox(tr("Window title")); + windowSystemMenuCheckBox = createCheckBox(tr("Window system menu")); + windowMinimizeButtonCheckBox = createCheckBox(tr("Window minimize button")); + windowMaximizeButtonCheckBox = createCheckBox(tr("Window maximize button")); + windowCloseButtonCheckBox = createCheckBox(tr("Window close button")); + windowContextHelpButtonCheckBox = + createCheckBox(tr("Window context help button")); + windowShadeButtonCheckBox = createCheckBox(tr("Window shade button")); + windowStaysOnTopCheckBox = createCheckBox(tr("Window stays on top")); + windowStaysOnBottomCheckBox = createCheckBox(tr("Window stays on bottom")); + customizeWindowHintCheckBox= createCheckBox(tr("Customize window")); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(msWindowsFixedSizeDialogCheckBox, 0, 0); + layout->addWidget(x11BypassWindowManagerCheckBox, 1, 0); + layout->addWidget(framelessWindowCheckBox, 2, 0); + layout->addWidget(windowTitleCheckBox, 3, 0); + layout->addWidget(windowSystemMenuCheckBox, 4, 0); + layout->addWidget(windowMinimizeButtonCheckBox, 0, 1); + layout->addWidget(windowMaximizeButtonCheckBox, 1, 1); + layout->addWidget(windowCloseButtonCheckBox, 2, 1); + layout->addWidget(windowContextHelpButtonCheckBox, 3, 1); + layout->addWidget(windowShadeButtonCheckBox, 4, 1); + layout->addWidget(windowStaysOnTopCheckBox, 5, 1); + layout->addWidget(windowStaysOnBottomCheckBox, 6, 1); + layout->addWidget(customizeWindowHintCheckBox, 5, 0); + hintsGroupBox->setLayout(layout); +} +//! [6] + +//! [7] +QCheckBox *ControllerWindow::createCheckBox(const QString &text) +{ + QCheckBox *checkBox = new QCheckBox(text); + connect(checkBox, SIGNAL(clicked()), this, SLOT(updatePreview())); + return checkBox; +} +//! [7] + +//! [8] +QRadioButton *ControllerWindow::createRadioButton(const QString &text) +{ + QRadioButton *button = new QRadioButton(text); + connect(button, SIGNAL(clicked()), this, SLOT(updatePreview())); + return button; +} +//! [8] diff --git a/tests/manual/windowflags/controllerwindow.h b/tests/manual/windowflags/controllerwindow.h new file mode 100644 index 0000000..3d315be --- /dev/null +++ b/tests/manual/windowflags/controllerwindow.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CONTROLLERWINDOW_H +#define CONTROLLERWINDOW_H + +#include <QWidget> + +#include "previewwindow.h" + +QT_BEGIN_NAMESPACE +class QCheckBox; +class QGroupBox; +class QLabel; +class QPushButton; +class QRadioButton; +class QMainWindow; +QT_END_NAMESPACE + +//! [0] +class ControllerWindow : public QWidget +{ + Q_OBJECT + +public: + ControllerWindow(); + +private slots: + void updatePreview(); + +private: + void createTypeGroupBox(); + void createHintsGroupBox(); + QCheckBox *createCheckBox(const QString &text); + QRadioButton *createRadioButton(const QString &text); + + QMainWindow *parentWindow; + PreviewWindow *previewWindow; + PreviewDialog *previewDialog; + + QGroupBox *widgetTypeGroupBox; + QGroupBox *additionalOptionsGroupBox; + QGroupBox *typeGroupBox; + QGroupBox *hintsGroupBox; + QPushButton *quitButton; + + QRadioButton *previewWidgetButton; + QRadioButton *previewDialogButton; + QCheckBox *modalWindowCheckBox; + QCheckBox *fixedSizeWindowCheckBox; + + QRadioButton *windowRadioButton; + QRadioButton *dialogRadioButton; + QRadioButton *sheetRadioButton; + QRadioButton *drawerRadioButton; + QRadioButton *popupRadioButton; + QRadioButton *toolRadioButton; + QRadioButton *toolTipRadioButton; + QRadioButton *splashScreenRadioButton; + + QCheckBox *msWindowsFixedSizeDialogCheckBox; + QCheckBox *x11BypassWindowManagerCheckBox; + QCheckBox *framelessWindowCheckBox; + QCheckBox *windowTitleCheckBox; + QCheckBox *windowSystemMenuCheckBox; + QCheckBox *windowMinimizeButtonCheckBox; + QCheckBox *windowMaximizeButtonCheckBox; + QCheckBox *windowCloseButtonCheckBox; + QCheckBox *windowContextHelpButtonCheckBox; + QCheckBox *windowShadeButtonCheckBox; + QCheckBox *windowStaysOnTopCheckBox; + QCheckBox *windowStaysOnBottomCheckBox; + QCheckBox *customizeWindowHintCheckBox; +}; +//! [0] + +#endif diff --git a/tests/manual/windowflags/main.cpp b/tests/manual/windowflags/main.cpp new file mode 100644 index 0000000..011ca3f --- /dev/null +++ b/tests/manual/windowflags/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> + +#include "controllerwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + ControllerWindow controller; + controller.show(); + return app.exec(); +} diff --git a/tests/manual/windowflags/previewwindow.cpp b/tests/manual/windowflags/previewwindow.cpp new file mode 100644 index 0000000..796bdb9 --- /dev/null +++ b/tests/manual/windowflags/previewwindow.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +#include "previewwindow.h" + +static QString windowFlagsToString(Qt::WindowFlags flags) +{ + QString text; + + Qt::WindowFlags type = (flags & Qt::WindowType_Mask); + if (type == Qt::Window) { + text = "Qt::Window"; + } else if (type == Qt::Dialog) { + text = "Qt::Dialog"; + } else if (type == Qt::Sheet) { + text = "Qt::Sheet"; + } else if (type == Qt::Drawer) { + text = "Qt::Drawer"; + } else if (type == Qt::Popup) { + text = "Qt::Popup"; + } else if (type == Qt::Tool) { + text = "Qt::Tool"; + } else if (type == Qt::ToolTip) { + text = "Qt::ToolTip"; + } else if (type == Qt::SplashScreen) { + text = "Qt::SplashScreen"; + } + + if (flags & Qt::MSWindowsFixedSizeDialogHint) + text += "\n| Qt::MSWindowsFixedSizeDialogHint"; + if (flags & Qt::X11BypassWindowManagerHint) + text += "\n| Qt::X11BypassWindowManagerHint"; + if (flags & Qt::FramelessWindowHint) + text += "\n| Qt::FramelessWindowHint"; + if (flags & Qt::WindowTitleHint) + text += "\n| Qt::WindowTitleHint"; + if (flags & Qt::WindowSystemMenuHint) + text += "\n| Qt::WindowSystemMenuHint"; + if (flags & Qt::WindowMinimizeButtonHint) + text += "\n| Qt::WindowMinimizeButtonHint"; + if (flags & Qt::WindowMaximizeButtonHint) + text += "\n| Qt::WindowMaximizeButtonHint"; + if (flags & Qt::WindowCloseButtonHint) + text += "\n| Qt::WindowCloseButtonHint"; + if (flags & Qt::WindowContextHelpButtonHint) + text += "\n| Qt::WindowContextHelpButtonHint"; + if (flags & Qt::WindowShadeButtonHint) + text += "\n| Qt::WindowShadeButtonHint"; + if (flags & Qt::WindowStaysOnTopHint) + text += "\n| Qt::WindowStaysOnTopHint"; + if (flags & Qt::CustomizeWindowHint) + text += "\n| Qt::CustomizeWindowHint"; + return text; +} + +PreviewWindow::PreviewWindow(QWidget *parent) + : QWidget(parent) +{ + textEdit = new QTextEdit; + textEdit->setReadOnly(true); + textEdit->setLineWrapMode(QTextEdit::NoWrap); + + closeButton = new QPushButton(tr("&Close")); + connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(textEdit); + layout->addWidget(closeButton); + setLayout(layout); + + setWindowTitle(tr("Preview <QWidget>")); +} + +void PreviewWindow::setWindowFlags(Qt::WindowFlags flags) +{ + QWidget::setWindowFlags(flags); + + QString text = windowFlagsToString(flags); + textEdit->setPlainText(text); +} + +PreviewDialog::PreviewDialog(QWidget *parent) + : QDialog(parent) +{ + textEdit = new QTextEdit; + textEdit->setReadOnly(true); + textEdit->setLineWrapMode(QTextEdit::NoWrap); + + closeButton = new QPushButton(tr("&Close")); + connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(textEdit); + layout->addWidget(closeButton); + setLayout(layout); + + setWindowTitle(tr("Preview <QDialog>")); +} + +void PreviewDialog::setWindowFlags(Qt::WindowFlags flags) +{ + QWidget::setWindowFlags(flags); + + QString text = windowFlagsToString(flags); + textEdit->setPlainText(text); +} diff --git a/tests/manual/windowflags/previewwindow.h b/tests/manual/windowflags/previewwindow.h new file mode 100644 index 0000000..90ed8ba --- /dev/null +++ b/tests/manual/windowflags/previewwindow.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PREVIEWWINDOW_H +#define PREVIEWWINDOW_H + +#include <QWidget> +#include <QDialog> + +QT_BEGIN_NAMESPACE +class QPushButton; +class QTextEdit; +QT_END_NAMESPACE + +class PreviewWindow : public QWidget +{ + Q_OBJECT + +public: + PreviewWindow(QWidget *parent = 0); + + void setWindowFlags(Qt::WindowFlags flags); + +private: + QTextEdit *textEdit; + QPushButton *closeButton; +}; + +class PreviewDialog : public QDialog +{ + Q_OBJECT + +public: + PreviewDialog(QWidget *parent = 0); + + void setWindowFlags(Qt::WindowFlags flags); + +private: + QTextEdit *textEdit; + QPushButton *closeButton; +}; + +#endif diff --git a/tests/manual/windowflags/windowflags.pro b/tests/manual/windowflags/windowflags.pro new file mode 100644 index 0000000..1b45d0d --- /dev/null +++ b/tests/manual/windowflags/windowflags.pro @@ -0,0 +1,5 @@ +HEADERS = controllerwindow.h \ + previewwindow.h +SOURCES = controllerwindow.cpp \ + previewwindow.cpp \ + main.cpp |