diff --git a/src/commands.hxx b/src/commands.hxx index 4a59303..dab9a2a 100644 --- a/src/commands.hxx +++ b/src/commands.hxx @@ -105,7 +105,7 @@ class Logger { }; class Command: public QObject { - Q_OBJECT; + Q_OBJECT public: Command(): _log(true), _line(-1), _indent(0) {} virtual ~Command() {} @@ -119,7 +119,7 @@ class Command: public QObject { log(QString(" FAILED[")+demangle(typeid(e).name())+"]: "+e.what()); throw e; } - virtual int steps(Script* parent) { + virtual int steps(Script*) { return 1; } void line(int linenr) { @@ -198,10 +198,11 @@ class Command: public QObject { QStringList args = QStringList()); QStringList subCommandBlock(QStringList& in) { QStringList commands; - int pos(-1); + std::string::size_type pos(std::string::npos); while (in.size() && in[0].size() && in[0][0]==' ' - && pos<=(signed)in[0].toStdString().find_first_not_of(' ')) { - if (pos<0) pos=in[0].toStdString().find_first_not_of(' '); + && (pos==std::string::npos || + pos<=in[0].toStdString().find_first_not_of(' '))) { + if (pos==std::string::npos) pos=in[0].toStdString().find_first_not_of(' '); commands += in.takeFirst().mid(pos); } return commands; @@ -252,7 +253,7 @@ class Command: public QObject { for (int i=0; ifindFirstElement(selector); if (!element.isNull()) return element; - Q_FOREACH(QWebFrame* childFrame, frame->childFrames()) { + for (QWebFrame* childFrame: frame->childFrames()) { element = find1(childFrame, selector, 1, 0); if (!element.isNull()) return element; } @@ -403,7 +404,7 @@ class Screenshot: public Command { }; class RunDownload: public QObject { - Q_OBJECT; + Q_OBJECT public: RunDownload(QNetworkReply* reply, QString filename): _reply(reply), _file(filename) { @@ -445,7 +446,7 @@ class RunDownload: public QObject { -# test scripts, see @ref testscript. */ class Script: public QObject { - Q_OBJECT; + Q_OBJECT Q_SIGNALS: void logging(QString); void progress(QString, int, int); @@ -486,17 +487,17 @@ class Script: public QObject { } public: Script(): - _step(0), _clicktype(JAVASCRIPT_CLICK), _command(0), - _screenshots(true), _defaultTimeout(20) { + _step(0), _clicktype(JAVASCRIPT_CLICK), + _screenshots(true), _command(0), _defaultTimeout(20) { initPrototypes(); } Script(const Script& o): QObject(), - _step(0), _prototypes(o._prototypes), + _step(0), _script(o._script), - _command(0), - _screenshots(true) { + _screenshots(true), + _command(0) { set(o); } QString syntax() const { @@ -861,7 +862,7 @@ class Script: public QObject { void ignore(QStringList sigs = QStringList()) { if (sigs.empty()) sigs<<"loadFinished"<<"loadStarted"<<"frameChanged"<<"titleChanged"<<"urlChanged"; - Q_FOREACH(const QString& sig, sigs) { + for (const QString& sig: sigs) { log("start ignoring: '"+sig+"'"); _ignore<countSteps()+1; } std::shared_ptr