summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorTobias Koenig <tokoe@kde.org>2009-06-10 15:11:59 (GMT)
committerTobias Koenig <tokoe@kde.org>2009-06-10 15:11:59 (GMT)
commitf1e6e89f7ee452af0e4404af537f5fed2a2b2dc5 (patch)
tree045fbf67a4806e4e217ef23cdf4f363ac359bef1 /examples
parent5d87f2542bbcb0877f4a9a9b5be4df80cd6aa4cd (diff)
parent5b24c5793607c809b1bac82c7cc3696001ee9217 (diff)
downloadQt-f1e6e89f7ee452af0e4404af537f5fed2a2b2dc5.zip
Qt-f1e6e89f7ee452af0e4404af537f5fed2a2b2dc5.tar.gz
Qt-f1e6e89f7ee452af0e4404af537f5fed2a2b2dc5.tar.bz2
Merge branch 'master' of git://gitorious.org/qt/qt
Diffstat (limited to 'examples')
-rw-r--r--examples/animation/easing/window.cpp40
-rw-r--r--examples/animation/stickman/node.h2
-rw-r--r--examples/network/http/httpwindow.cpp4
-rw-r--r--examples/richtext/textobject/textobject.pro4
-rw-r--r--examples/statemachine/eventtransitions/main.cpp5
-rw-r--r--examples/statemachine/factorial/main.cpp6
-rw-r--r--examples/statemachine/pingpong/main.cpp5
-rw-r--r--examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp5
-rw-r--r--examples/statemachine/trafficlight/main.cpp5
-rw-r--r--examples/statemachine/twowaybutton/main.cpp4
-rw-r--r--examples/tutorials/addressbook-fr/part3/addressbook.cpp4
-rw-r--r--examples/tutorials/addressbook-fr/part4/addressbook.cpp3
-rw-r--r--examples/tutorials/addressbook-fr/part5/addressbook.cpp3
-rw-r--r--examples/tutorials/addressbook-fr/part6/addressbook.cpp3
-rw-r--r--examples/tutorials/addressbook-fr/part7/addressbook.cpp3
15 files changed, 37 insertions, 59 deletions
diff --git a/examples/animation/easing/window.cpp b/examples/animation/easing/window.cpp
index cf4be15..3e44873 100644
--- a/examples/animation/easing/window.cpp
+++ b/examples/animation/easing/window.cpp
@@ -41,28 +41,28 @@
#include "window.h"
-Window::Window(QWidget *parent)
+Window::Window(QWidget *parent)
: QWidget(parent), m_iconSize(64, 64)
{
m_ui.setupUi(this);
QButtonGroup *buttonGroup = qFindChild<QButtonGroup *>(this); // ### workaround for uic in 4.4
- m_ui.easingCurvePicker->setIconSize(m_iconSize);
+ m_ui.easingCurvePicker->setIconSize(m_iconSize);
m_ui.easingCurvePicker->setMinimumHeight(m_iconSize.height() + 50);
buttonGroup->setId(m_ui.lineRadio, 0);
buttonGroup->setId(m_ui.circleRadio, 1);
-
+
QEasingCurve dummy;
m_ui.periodSpinBox->setValue(dummy.period());
m_ui.amplitudeSpinBox->setValue(dummy.amplitude());
m_ui.overshootSpinBox->setValue(dummy.overshoot());
-
+
connect(m_ui.easingCurvePicker, SIGNAL(currentRowChanged(int)), this, SLOT(curveChanged(int)));
connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(pathChanged(int)));
connect(m_ui.periodSpinBox, SIGNAL(valueChanged(double)), this, SLOT(periodChanged(double)));
connect(m_ui.amplitudeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(amplitudeChanged(double)));
connect(m_ui.overshootSpinBox, SIGNAL(valueChanged(double)), this, SLOT(overshootChanged(double)));
createCurveIcons();
-
+
QPixmap pix(QLatin1String(":/images/qt-logo.png"));
m_item = new PixmapItem(pix);
m_scene.addItem(m_item);
@@ -94,18 +94,32 @@ void Window::createCurveIcons()
qreal yAxis = m_iconSize.width()/3;
painter.drawLine(0, xAxis, m_iconSize.width(), xAxis);
painter.drawLine(yAxis, 0, yAxis, m_iconSize.height());
- painter.setPen(Qt::black);
-
+
qreal curveScale = m_iconSize.height()/2;
- QPoint currentPos(yAxis, xAxis);
-
- for (qreal t = 0; t < 1.0; t+=1.0/curveScale) {
+
+ painter.setPen(Qt::NoPen);
+
+ // start point
+ painter.setBrush(Qt::red);
+ QPoint start(yAxis, xAxis - curveScale * curve.valueForProgress(0));
+ painter.drawRect(start.x() - 1, start.y() - 1, 3, 3);
+
+ // end point
+ painter.setBrush(Qt::blue);
+ QPoint end(yAxis + curveScale, xAxis - curveScale * curve.valueForProgress(1));
+ painter.drawRect(end.x() - 1, end.y() - 1, 3, 3);
+
+ QPainterPath curvePath;
+ curvePath.moveTo(start);
+ for (qreal t = 0; t <= 1.0; t+=1.0/curveScale) {
QPoint to;
to.setX(yAxis + curveScale * t);
to.setY(xAxis - curveScale * curve.valueForProgress(t));
- painter.drawLine(currentPos, to);
- currentPos = to;
+ curvePath.lineTo(to);
}
+ painter.setRenderHint(QPainter::Antialiasing, true);
+ painter.strokePath(curvePath, QColor(32, 32, 32));
+ painter.setRenderHint(QPainter::Antialiasing, false);
QListWidgetItem *item = new QListWidgetItem;
item->setIcon(QIcon(pix));
item->setText(metaEnum.key(i));
@@ -127,7 +141,7 @@ void Window::curveChanged(int row)
QEasingCurve::Type curveType = (QEasingCurve::Type)row;
m_anim->setEasingCurve(curveType);
m_anim->setCurrentTime(0);
-
+
bool isElastic = curveType >= QEasingCurve::InElastic && curveType <= QEasingCurve::OutInElastic;
bool isBounce = curveType >= QEasingCurve::InBounce && curveType <= QEasingCurve::OutInBounce;
m_ui.periodSpinBox->setEnabled(isElastic);
diff --git a/examples/animation/stickman/node.h b/examples/animation/stickman/node.h
index 72eae87..8654144 100644
--- a/examples/animation/stickman/node.h
+++ b/examples/animation/stickman/node.h
@@ -47,7 +47,7 @@
class Node: public QObject, public QGraphicsItem
{
Q_OBJECT
- Q_PROPERTY(QPointF position READ pos WRITE setPos);
+ Q_PROPERTY(QPointF position READ pos WRITE setPos)
public:
Node(const QPointF &pos, QGraphicsItem *parent = 0);
~Node();
diff --git a/examples/network/http/httpwindow.cpp b/examples/network/http/httpwindow.cpp
index ebde770..7aded07 100644
--- a/examples/network/http/httpwindow.cpp
+++ b/examples/network/http/httpwindow.cpp
@@ -116,8 +116,8 @@ void HttpWindow::downloadFile()
if (QMessageBox::question(this, tr("HTTP"),
tr("There already exists a file called %1 in "
"the current directory. Overwrite?").arg(fileName),
- QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Cancel)
- == QMessageBox::Cancel)
+ QMessageBox::Yes|QMessageBox::No, QMessageBox::No)
+ == QMessageBox::No)
return;
QFile::remove(fileName);
}
diff --git a/examples/richtext/textobject/textobject.pro b/examples/richtext/textobject/textobject.pro
index fbb809c..4fa9cb0 100644
--- a/examples/richtext/textobject/textobject.pro
+++ b/examples/richtext/textobject/textobject.pro
@@ -12,3 +12,7 @@ sources.files = $$SOURCES $$HEADERS *.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/richtext/textobject
INSTALLS += target sources
+filesToDeploy.sources = files/*.svg
+filesToDeploy.path = files
+DEPLOYMENT += filesToDeploy
+
diff --git a/examples/statemachine/eventtransitions/main.cpp b/examples/statemachine/eventtransitions/main.cpp
index aba0c73..5959016 100644
--- a/examples/statemachine/eventtransitions/main.cpp
+++ b/examples/statemachine/eventtransitions/main.cpp
@@ -40,11 +40,6 @@
****************************************************************************/
#include <QtGui>
-#ifdef QT_STATEMACHINE_SOLUTION
-#include <qstatemachine.h>
-#include <qstate.h>
-#include <qeventtransition.h>
-#endif
//! [0]
class Window : public QWidget
diff --git a/examples/statemachine/factorial/main.cpp b/examples/statemachine/factorial/main.cpp
index 1065eb8..bf3f80e 100644
--- a/examples/statemachine/factorial/main.cpp
+++ b/examples/statemachine/factorial/main.cpp
@@ -41,12 +41,6 @@
#include <QtCore>
#include <stdio.h>
-#ifdef QT_STATEMACHINE_SOLUTION
-#include <qstatemachine.h>
-#include <qstate.h>
-#include <qsignaltransition.h>
-#include <qfinalstate.h>
-#endif
//! [0]
class Factorial : public QObject
diff --git a/examples/statemachine/pingpong/main.cpp b/examples/statemachine/pingpong/main.cpp
index 331627e..586b422 100644
--- a/examples/statemachine/pingpong/main.cpp
+++ b/examples/statemachine/pingpong/main.cpp
@@ -41,11 +41,6 @@
#include <QtCore>
#include <stdio.h>
-#ifdef QT_STATEMACHINE_SOLUTION
-#include <qstate.h>
-#include <qstatemachine.h>
-#include <qabstracttransition.h>
-#endif
//! [0]
class PingEvent : public QEvent
diff --git a/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp b/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp
index d360de9..2368608 100644
--- a/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp
+++ b/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp
@@ -42,13 +42,12 @@
#include "random_ai_plugin.h"
#include <QState>
+#include <QTime>
#include <QtPlugin>
-#include <time.h>
-
QState *RandomAiPlugin::create(QState *parentState, QObject *tank)
{
- qsrand(uint(time(NULL)));
+ qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
QState *topLevel = new QState(parentState);
diff --git a/examples/statemachine/trafficlight/main.cpp b/examples/statemachine/trafficlight/main.cpp
index 8a46fff..23f4bed 100644
--- a/examples/statemachine/trafficlight/main.cpp
+++ b/examples/statemachine/trafficlight/main.cpp
@@ -40,11 +40,6 @@
****************************************************************************/
#include <QtGui>
-#ifdef QT_STATEMACHINE_SOLUTION
-#include <qstate.h>
-#include <qstatemachine.h>
-#include <qfinalstate.h>
-#endif
//! [0]
class LightWidget : public QWidget
diff --git a/examples/statemachine/twowaybutton/main.cpp b/examples/statemachine/twowaybutton/main.cpp
index a2c6e45..f5afeca 100644
--- a/examples/statemachine/twowaybutton/main.cpp
+++ b/examples/statemachine/twowaybutton/main.cpp
@@ -40,10 +40,6 @@
****************************************************************************/
#include <QtGui>
-#ifdef QT_STATEMACHINE_SOLUTION
-#include <qstate.h>
-#include <qstatemachine.h>
-#endif
//! [0]
int main(int argc, char **argv)
diff --git a/examples/tutorials/addressbook-fr/part3/addressbook.cpp b/examples/tutorials/addressbook-fr/part3/addressbook.cpp
index 49c5206..332e808 100644
--- a/examples/tutorials/addressbook-fr/part3/addressbook.cpp
+++ b/examples/tutorials/addressbook-fr/part3/addressbook.cpp
@@ -125,8 +125,7 @@ void AddressBook::submitContact()
if (name == "" || address == "") {
QMessageBox::information(this, tr("Empty Field"),
- tr("Please enter a name and adderss."));
- return;
+ tr("Please enter a name and address."));
}
if (!contacts.contains(name)) {
@@ -136,7 +135,6 @@ void AddressBook::submitContact()
} else {
QMessageBox::information(this, tr("Add Unsuccessful"),
tr("Sorry, \"%1\" is already in your address book.").arg(name));
- return;
}
if (contacts.isEmpty()) {
diff --git a/examples/tutorials/addressbook-fr/part4/addressbook.cpp b/examples/tutorials/addressbook-fr/part4/addressbook.cpp
index 95def9c..06f8a09 100644
--- a/examples/tutorials/addressbook-fr/part4/addressbook.cpp
+++ b/examples/tutorials/addressbook-fr/part4/addressbook.cpp
@@ -135,7 +135,6 @@ void AddressBook::submitContact()
if (name == "" || address == "") {
QMessageBox::information(this, tr("Empty Field"),
tr("Please enter a name and address."));
- return;
}
//! [submitContact() function part1]
if (currentMode == AddingMode) {
@@ -147,7 +146,6 @@ void AddressBook::submitContact()
} else {
QMessageBox::information(this, tr("Add Unsuccessful"),
tr("Sorry, \"%1\" is already in your address book.").arg(name));
- return;
}
//! [submitContact() function part1]
//! [submitContact() function part2]
@@ -162,7 +160,6 @@ void AddressBook::submitContact()
} else {
QMessageBox::information(this, tr("Edit Unsuccessful"),
tr("Sorry, \"%1\" is already in your address book.").arg(name));
- return;
}
} else if (oldAddress != address) {
QMessageBox::information(this, tr("Edit Successful"),
diff --git a/examples/tutorials/addressbook-fr/part5/addressbook.cpp b/examples/tutorials/addressbook-fr/part5/addressbook.cpp
index 5afb6b8..af3c2d0 100644
--- a/examples/tutorials/addressbook-fr/part5/addressbook.cpp
+++ b/examples/tutorials/addressbook-fr/part5/addressbook.cpp
@@ -142,7 +142,6 @@ void AddressBook::submitContact()
if (name == "" || address == "") {
QMessageBox::information(this, tr("Empty Field"),
tr("Please enter a name and address."));
- return;
}
if (currentMode == AddingMode) {
@@ -154,7 +153,6 @@ void AddressBook::submitContact()
} else {
QMessageBox::information(this, tr("Add Unsuccessful"),
tr("Sorry, \"%1\" is already in your address book.").arg(name));
- return;
}
} else if (currentMode == EditingMode) {
@@ -167,7 +165,6 @@ void AddressBook::submitContact()
} else {
QMessageBox::information(this, tr("Edit Unsuccessful"),
tr("Sorry, \"%1\" is already in your address book.").arg(name));
- return;
}
} else if (oldAddress != address) {
QMessageBox::information(this, tr("Edit Successful"),
diff --git a/examples/tutorials/addressbook-fr/part6/addressbook.cpp b/examples/tutorials/addressbook-fr/part6/addressbook.cpp
index b7cd446..5f31c99 100644
--- a/examples/tutorials/addressbook-fr/part6/addressbook.cpp
+++ b/examples/tutorials/addressbook-fr/part6/addressbook.cpp
@@ -148,7 +148,6 @@ void AddressBook::submitContact()
if (name == "" || address == "") {
QMessageBox::information(this, tr("Empty Field"),
tr("Please enter a name and address."));
- return;
}
if (currentMode == AddingMode) {
@@ -160,7 +159,6 @@ void AddressBook::submitContact()
} else {
QMessageBox::information(this, tr("Add Unsuccessful"),
tr("Sorry, \"%1\" is already in your address book.").arg(name));
- return;
}
} else if (currentMode == EditingMode) {
@@ -173,7 +171,6 @@ void AddressBook::submitContact()
} else {
QMessageBox::information(this, tr("Edit Unsuccessful"),
tr("Sorry, \"%1\" is already in your address book.").arg(name));
- return;
}
} else if (oldAddress != address) {
QMessageBox::information(this, tr("Edit Successful"),
diff --git a/examples/tutorials/addressbook-fr/part7/addressbook.cpp b/examples/tutorials/addressbook-fr/part7/addressbook.cpp
index 2f81d2b..8be4d2b 100644
--- a/examples/tutorials/addressbook-fr/part7/addressbook.cpp
+++ b/examples/tutorials/addressbook-fr/part7/addressbook.cpp
@@ -150,7 +150,6 @@ void AddressBook::submitContact()
if (name == "" || address == "") {
QMessageBox::information(this, tr("Empty Field"),
tr("Please enter a name and address."));
- return;
}
if (currentMode == AddingMode) {
@@ -162,7 +161,6 @@ void AddressBook::submitContact()
} else {
QMessageBox::information(this, tr("Add Unsuccessful"),
tr("Sorry, \"%1\" is already in your address book.").arg(name));
- return;
}
} else if (currentMode == EditingMode) {
@@ -175,7 +173,6 @@ void AddressBook::submitContact()
} else {
QMessageBox::information(this, tr("Edit Unsuccessful"),
tr("Sorry, \"%1\" is already in your address book.").arg(name));
- return;
}
} else if (oldAddress != address) {
QMessageBox::information(this, tr("Edit Successful"),