summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2018-04-30 16:24:45 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2018-05-02 08:28:46 +0000
commite2eac34b3d6cac1413492b5a0ca56b39c7531442 (patch)
treedd4b50f30dbaa70194c6f16c0e8e5a1b22798597 /examples
parentca2ad9a474bb3df56ba65447d74b73cf8f17ae3a (diff)
Wrap examples' code at 80 column
According to https://wiki.qt.io/Writing_Qt_Examples Task-number: QTBUG-60649 Change-Id: I17073bb3caf32ccd17d93542876a73ed939f12bd Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/scxml/calculator-widgets/mainwindow.cpp6
-rw-r--r--examples/scxml/ftpclient/ftpcontrolchannel.cpp9
-rw-r--r--examples/scxml/ftpclient/ftpdatachannel.h3
-rw-r--r--examples/scxml/ftpclient/main.cpp9
-rw-r--r--examples/scxml/mediaplayer-common/mainwindow.cpp12
-rw-r--r--examples/scxml/mediaplayer-common/mainwindow.h3
-rw-r--r--examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp3
-rw-r--r--examples/scxml/sudoku/mainwindow.cpp27
-rw-r--r--examples/scxml/trafficlight-common/trafficlight.cpp6
-rw-r--r--examples/scxml/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp3
10 files changed, 54 insertions, 27 deletions
diff --git a/examples/scxml/calculator-widgets/mainwindow.cpp b/examples/scxml/calculator-widgets/mainwindow.cpp
index 687c5a9..b742b95 100644
--- a/examples/scxml/calculator-widgets/mainwindow.cpp
+++ b/examples/scxml/calculator-widgets/mainwindow.cpp
@@ -115,8 +115,10 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
m_machine->submitEvent("C");
});
- m_machine->connectToEvent(QLatin1String("updateDisplay"), this, [this](const QScxmlEvent &event) {
- const QString display = event.data().toMap().value("display").toString();
+ m_machine->connectToEvent(QLatin1String("updateDisplay"), this,
+ [this](const QScxmlEvent &event) {
+ const QString display = event.data().toMap()
+ .value("display").toString();
ui->display->setText(display);
});
}
diff --git a/examples/scxml/ftpclient/ftpcontrolchannel.cpp b/examples/scxml/ftpclient/ftpcontrolchannel.cpp
index c37b6e5..5f58105 100644
--- a/examples/scxml/ftpclient/ftpcontrolchannel.cpp
+++ b/examples/scxml/ftpclient/ftpcontrolchannel.cpp
@@ -52,8 +52,10 @@
FtpControlChannel::FtpControlChannel(QObject *parent) : QObject(parent)
{
- connect(&m_socket, &QIODevice::readyRead, this, &FtpControlChannel::onReadyRead);
- connect(&m_socket, &QAbstractSocket::disconnected, this, &FtpControlChannel::closed);
+ connect(&m_socket, &QIODevice::readyRead,
+ this, &FtpControlChannel::onReadyRead);
+ connect(&m_socket, &QAbstractSocket::disconnected,
+ this, &FtpControlChannel::closed);
connect(&m_socket, &QAbstractSocket::connected, this, [this]() {
emit opened(m_socket.localAddress(), m_socket.localPort());
});
@@ -64,7 +66,8 @@ void FtpControlChannel::connectToServer(const QString &server)
m_socket.connectToHost(server, 21);
}
-void FtpControlChannel::command(const QByteArray &command, const QByteArray &params)
+void FtpControlChannel::command(const QByteArray &command,
+ const QByteArray &params)
{
QByteArray sendData = command;
if (!params.isEmpty())
diff --git a/examples/scxml/ftpclient/ftpdatachannel.h b/examples/scxml/ftpclient/ftpdatachannel.h
index fb1b6ef..2418196 100644
--- a/examples/scxml/ftpclient/ftpdatachannel.h
+++ b/examples/scxml/ftpclient/ftpdatachannel.h
@@ -75,7 +75,8 @@ public:
// Something like "a,b,c,d,xxx,yyy" where
// - a.b.c.d would be the IP address in decimal/dot notation and
// - xxx,yyy are the upper and lower 8 bits of the TCP port in decimal
- // (This will only work if the local address we're listening on is actually meaningful)
+ // (This will only work if the local address we're listening on
+ // is actually meaningful)
QString portspec() const;
signals:
diff --git a/examples/scxml/ftpclient/main.cpp b/examples/scxml/ftpclient/main.cpp
index 167bb6f..b285077 100644
--- a/examples/scxml/ftpclient/main.cpp
+++ b/examples/scxml/ftpclient/main.cpp
@@ -77,14 +77,16 @@ int main(int argc, char *argv[])
FtpControlChannel controlChannel;
// Print all data retrieved from the server on the console.
- QObject::connect(&dataChannel, &FtpDataChannel::dataReceived, [](const QByteArray &data) {
+ QObject::connect(&dataChannel, &FtpDataChannel::dataReceived,
+ [](const QByteArray &data) {
std::cout << data.constData();
});
// Translate server replies into state machine events.
QObject::connect(&controlChannel, &FtpControlChannel::reply, &ftpClient,
[&ftpClient](int code, const QString &parameters) {
- ftpClient.submitEvent(QString("reply.%1xx").arg(code / 100), parameters);
+ ftpClient.submitEvent(QString("reply.%1xx")
+ .arg(code / 100), parameters);
});
// Translate commands from the state machine into FTP control messages.
@@ -97,7 +99,8 @@ int main(int argc, char *argv[])
// Commands to be sent
QList<Command> commands({
{"cmd.USER", "anonymous"},// login
- {"cmd.PORT", ""}, // announce port for data connection, args added below.
+ {"cmd.PORT", ""}, // announce port for data connection,
+ // args added below.
{"cmd.RETR", file} // retrieve a file
});
diff --git a/examples/scxml/mediaplayer-common/mainwindow.cpp b/examples/scxml/mediaplayer-common/mainwindow.cpp
index b9ff727..cedb072 100644
--- a/examples/scxml/mediaplayer-common/mainwindow.cpp
+++ b/examples/scxml/mediaplayer-common/mainwindow.cpp
@@ -64,13 +64,15 @@ MainWindow::MainWindow(QScxmlStateMachine *stateMachine, QWidget *parent) :
auto model = new QStringListModel(QStringList() << QStringLiteral("song 1")
<< QStringLiteral("song 2")
- << QStringLiteral("song 3"), this);
+ << QStringLiteral("song 3"),
+ this);
ui->mediaListView->setModel(model);
connect(ui->mediaListView, &QAbstractItemView::clicked,
[model, stateMachine](const QModelIndex &index) {
QVariantMap data;
- data.insert(QStringLiteral("media"), model->data(index, Qt::EditRole).toString());
+ data.insert(QStringLiteral("media"),
+ model->data(index, Qt::EditRole).toString());
stateMachine->submitEvent("tap", data);
});
@@ -86,13 +88,15 @@ MainWindow::~MainWindow()
void MainWindow::started(const QScxmlEvent &event)
{
const QString media = event.data().toMap().value("media").toString();
- ui->logText->appendPlainText(QStringLiteral("call on slot started with media '%1'").arg(media));
+ ui->logText->appendPlainText(QStringLiteral(
+ "call on slot started with media '%1'").arg(media));
ui->statusLabel->setText(QStringLiteral("Playing %1").arg(media));
}
void MainWindow::stopped(const QScxmlEvent &event)
{
const QString media = event.data().toMap().value("media").toString();
- ui->logText->appendPlainText(QStringLiteral("call on slot stopped with media '%1'").arg(media));
+ ui->logText->appendPlainText(QStringLiteral(
+ "call on slot stopped with media '%1'").arg(media));
ui->statusLabel->setText(QStringLiteral("Stopped"));
}
diff --git a/examples/scxml/mediaplayer-common/mainwindow.h b/examples/scxml/mediaplayer-common/mainwindow.h
index 9f26433..59ae27a 100644
--- a/examples/scxml/mediaplayer-common/mainwindow.h
+++ b/examples/scxml/mediaplayer-common/mainwindow.h
@@ -68,7 +68,8 @@ class MainWindow : public QWidget
Q_OBJECT
public:
- explicit MainWindow(QScxmlStateMachine *stateMachine, QWidget *parent = nullptr);
+ explicit MainWindow(QScxmlStateMachine *stateMachine,
+ QWidget *parent = nullptr);
~MainWindow();
private slots:
diff --git a/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp b/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp
index 63625fe..edc62e7 100644
--- a/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp
+++ b/examples/scxml/mediaplayer-widgets-dynamic/mediaplayer-widgets-dynamic.cpp
@@ -57,7 +57,8 @@ int main(int argc, char **argv)
{
QApplication app(argc, argv);
- auto machine = QScxmlStateMachine::fromFile(QStringLiteral(":mediaplayer.scxml"));
+ auto machine = QScxmlStateMachine::fromFile(
+ QStringLiteral(":mediaplayer.scxml"));
MainWindow mainWindow(machine);
machine->setParent(&mainWindow);
diff --git a/examples/scxml/sudoku/mainwindow.cpp b/examples/scxml/sudoku/mainwindow.cpp
index d54fc26..a95f59c 100644
--- a/examples/scxml/sudoku/mainwindow.cpp
+++ b/examples/scxml/sudoku/mainwindow.cpp
@@ -114,7 +114,8 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
for (int i = 0; i < Size; i++) {
for (int j = 0; j < Size; j++) {
QToolButton *button = new QToolButton(this);
- button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ button->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Expanding);
layout->addWidget(button, i + i / 3, j + j / 3);
m_buttons[i][j] = button;
connect(button, &QToolButton::clicked, [this, i, j] () {
@@ -139,7 +140,8 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
}
m_startButton = new QToolButton(this);
- m_startButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ m_startButton->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Expanding);
m_startButton->setText(tr("Start"));
layout->addWidget(m_startButton, Size + 3, 0, 1, 3);
@@ -156,7 +158,8 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
layout->addWidget(m_label, Size + 3, 4, 1, 3);
m_undoButton = new QToolButton(this);
- m_undoButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ m_undoButton->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Expanding);
m_undoButton->setText(tr("Undo"));
m_undoButton->setEnabled(false);
layout->addWidget(m_undoButton, Size + 3, 8, 1, 3);
@@ -170,9 +173,12 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
layout->addWidget(m_chooser, Size + 4, 0, 1, 11);
QDir dataDir(QLatin1String(":/data"));
- QFileInfoList sudokuFiles = dataDir.entryInfoList(QStringList() << "*.data");
- foreach (const QFileInfo &sudokuFile, sudokuFiles)
- m_chooser->addItem(sudokuFile.completeBaseName(), sudokuFile.absoluteFilePath());
+ QFileInfoList sudokuFiles = dataDir.entryInfoList(QStringList()
+ << "*.data");
+ foreach (const QFileInfo &sudokuFile, sudokuFiles) {
+ m_chooser->addItem(sudokuFile.completeBaseName(),
+ sudokuFile.absoluteFilePath());
+ }
connect(m_chooser, QOverload<int>::of(&QComboBox::currentIndexChanged),
[this] (int index) {
@@ -181,7 +187,8 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
m_machine->submitEvent("setup", initValues);
});
- const QVariantMap initValues = readSudoku(m_chooser->itemData(0).toString());
+ const QVariantMap initValues = readSudoku(
+ m_chooser->itemData(0).toString());
m_machine->setInitialValues(initValues);
m_machine->connectToState("playing", [this] (bool playing) {
@@ -206,7 +213,8 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
m_machine->connectToEvent("updateGUI", [this] (const QScxmlEvent &event) {
const QVariant data = event.data();
- const QVariantList currentRows = data.toMap().value("currentState").toList();
+ const QVariantList currentRows = data.toMap().value(
+ "currentState").toList();
for (int i = 0; i < currentRows.count(); i++) {
const QVariantList row = currentRows.at(i).toList();
for (int j = 0; j < row.count(); j++) {
@@ -223,7 +231,8 @@ MainWindow::MainWindow(QScxmlStateMachine *machine, QWidget *parent) :
const QVariantList row = initRows.at(i).toList();
for (int j = 0; j < row.count(); j++) {
const int value = row.at(j).toInt();
- const bool enabled = !value && active; // enable only zeroes from initState
+ // enable only zeroes from initState
+ const bool enabled = !value && active;
m_buttons[i][j]->setEnabled(enabled);
}
}
diff --git a/examples/scxml/trafficlight-common/trafficlight.cpp b/examples/scxml/trafficlight-common/trafficlight.cpp
index 72f79f0..52be91d 100644
--- a/examples/scxml/trafficlight-common/trafficlight.cpp
+++ b/examples/scxml/trafficlight-common/trafficlight.cpp
@@ -117,13 +117,15 @@ TrafficLight::TrafficLight(QScxmlStateMachine *machine, QWidget *parent)
QAbstractButton *button = new ButtonWidget(this);
auto setButtonGeometry = [this, button](){
QSize buttonSize = button->sizeHint();
- button->setGeometry(width() - buttonSize.width() - 20, height() - buttonSize.height() - 20,
+ button->setGeometry(width() - buttonSize.width() - 20,
+ height() - buttonSize.height() - 20,
buttonSize.width(), buttonSize.height());
};
connect(button, &QAbstractButton::toggled, this, setButtonGeometry);
setButtonGeometry();
- connect(button, &QAbstractButton::toggled, this, &TrafficLight::toggleWorking);
+ connect(button, &QAbstractButton::toggled,
+ this, &TrafficLight::toggleWorking);
}
void TrafficLight::toggleWorking(bool pause)
diff --git a/examples/scxml/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp b/examples/scxml/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp
index 7b0489e..10f52dc 100644
--- a/examples/scxml/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp
+++ b/examples/scxml/trafficlight-widgets-dynamic/trafficlight-widgets-dynamic.cpp
@@ -57,7 +57,8 @@ int main(int argc, char **argv)
{
QApplication app(argc, argv);
- QScxmlStateMachine *machine = QScxmlStateMachine::fromFile(QStringLiteral(":statemachine.scxml"));
+ QScxmlStateMachine *machine = QScxmlStateMachine::fromFile(
+ QStringLiteral(":statemachine.scxml"));
if (!machine->parseErrors().isEmpty()) {
QTextStream errs(stderr, QIODevice::WriteOnly);
const auto errors = machine->parseErrors();