Replace QString with const QString&

pull/14/head
wh201906 4 years ago
parent 862f0775f8
commit f2d00ee088

@ -14,7 +14,7 @@ PM3Process::PM3Process(QThread* thread, QObject* parent): QProcess(parent)
connect(this, &PM3Process::readyRead, this, &PM3Process::onReadyRead); connect(this, &PM3Process::readyRead, this, &PM3Process::onReadyRead);
} }
void PM3Process::connectPM3(const QString path, const QString port) void PM3Process::connectPM3(const QString& path, const QString& port)
{ {
QString result; QString result;
Util::ClientType clientType = Util::CLIENTTYPE_OFFICIAL; Util::ClientType clientType = Util::CLIENTTYPE_OFFICIAL;
@ -93,7 +93,6 @@ void PM3Process::testThread()
qDebug() << "PM3:" << QThread::currentThread(); qDebug() << "PM3:" << QThread::currentThread();
} }
qint64 PM3Process::write(QString data) qint64 PM3Process::write(QString data)
{ {
return QProcess::write(data.toLatin1()); return QProcess::write(data.toLatin1());

@ -21,7 +21,7 @@ public:
void testThread(); void testThread();
public slots: public slots:
void connectPM3(const QString path, const QString port); void connectPM3(const QString& path, const QString& port);
void setSerialListener(const QString& name, bool state); void setSerialListener(const QString& name, bool state);
qint64 write(QString data); qint64 write(QString data);
private slots: private slots:
@ -34,8 +34,8 @@ private:
QTimer* serialListener; QTimer* serialListener;
QSerialPortInfo* portInfo; QSerialPortInfo* portInfo;
signals: signals:
void PM3StatedChanged(bool st, QString info = ""); void PM3StatedChanged(bool st, const QString& info = "");
void newOutput(QString output); void newOutput(const QString& output);
void changeClientType(Util::ClientType); void changeClientType(Util::ClientType);
}; };

@ -9,7 +9,7 @@ Util::Util(QObject *parent) : QObject(parent)
qRegisterMetaType<Util::ClientType>("Util::ClientType"); qRegisterMetaType<Util::ClientType>("Util::ClientType");
} }
void Util::processOutput(QString output) void Util::processOutput(const QString& output)
{ {
// qDebug() << "Util::processOutput:" << output; // qDebug() << "Util::processOutput:" << output;
if(isRequiringOutput) if(isRequiringOutput)
@ -20,14 +20,14 @@ void Util::processOutput(QString output)
emit refreshOutput(output); emit refreshOutput(output);
} }
void Util::execCMD(QString cmd) void Util::execCMD(const QString& cmd)
{ {
qDebug() << cmd; qDebug() << cmd;
if(isRunning) if(isRunning)
emit write(cmd + "\r\n"); emit write(cmd + "\r\n");
} }
QString Util::execCMDWithOutput(QString cmd, ReturnTrigger trigger) QString Util::execCMDWithOutput(const QString& cmd, ReturnTrigger trigger)
{ {
bool isResultFound = false; bool isResultFound = false;
QRegularExpression re; QRegularExpression re;

@ -30,12 +30,12 @@ public:
waitTime = time; waitTime = time;
expectedOutputs = QStringList(); expectedOutputs = QStringList();
} }
ReturnTrigger(QStringList outputs) ReturnTrigger(const QStringList& outputs)
{ {
waitTime = 10000; waitTime = 10000;
expectedOutputs = outputs; expectedOutputs = outputs;
} }
ReturnTrigger(unsigned long time, QStringList outputs) ReturnTrigger(unsigned long time, const QStringList& outputs)
{ {
waitTime = time; waitTime = time;
expectedOutputs = outputs; expectedOutputs = outputs;
@ -46,12 +46,12 @@ public:
explicit Util(QObject *parent = nullptr); explicit Util(QObject *parent = nullptr);
void execCMD(QString cmd); void execCMD(const QString& cmd);
QString execCMDWithOutput(QString cmd, ReturnTrigger trigger = 10000); QString execCMDWithOutput(const QString& cmd, ReturnTrigger trigger = 10000);
void delay(unsigned int msec); void delay(unsigned int msec);
ClientType getClientType(); ClientType getClientType();
public slots: public slots:
void processOutput(QString output); void processOutput(const QString& output);
void setClientType(Util::ClientType clientType); void setClientType(Util::ClientType clientType);
void setRunningState(bool st); void setRunningState(bool st);
@ -63,7 +63,7 @@ private:
ClientType clientType; ClientType clientType;
signals: signals:
void refreshOutput(const QString& output); void refreshOutput(const QString& output);
void write(QString data); void write(QString data); // connected to PM3Process::write(QString data);
}; };
#endif // UTIL_H #endif // UTIL_H

@ -86,7 +86,7 @@ void MainWindow::on_PM3_connectButton_clicked()
} }
} }
void MainWindow::onPM3StateChanged(bool st, QString info) void MainWindow::onPM3StateChanged(bool st, const QString& info)
{ {
pm3state = st; pm3state = st;
setState(st); setState(st);

@ -47,7 +47,7 @@ public slots:
void refreshOutput(const QString& output); void refreshOutput(const QString& output);
void refreshCMD(const QString& cmd); void refreshCMD(const QString& cmd);
void setStatusBar(QLabel* target, const QString& text); void setStatusBar(QLabel* target, const QString& text);
void onPM3StateChanged(bool st, QString info); void onPM3StateChanged(bool st, const QString& info);
void MF_onTypeChanged(int id, bool st); void MF_onTypeChanged(int id, bool st);
private slots: private slots:
@ -179,7 +179,7 @@ private:
void setState(bool st); void setState(bool st);
void saveClientPath(const QString& path); void saveClientPath(const QString& path);
signals: signals:
void connectPM3(const QString path, const QString port); void connectPM3(const QString& path, const QString& port);
void killPM3(); void killPM3();
void setSerialListener(const QString& name, bool state); void setSerialListener(const QString& name, bool state);
}; };

@ -3,7 +3,8 @@
#include <QDialog> #include <QDialog>
namespace Ui { namespace Ui
{
class MF_Attack_hardnestedDialog; class MF_Attack_hardnestedDialog;
} }
@ -19,7 +20,7 @@ public:
private: private:
Ui::MF_Attack_hardnestedDialog *ui; Ui::MF_Attack_hardnestedDialog *ui;
signals: signals:
void sendCMD(QString cmd); void sendCMD(const QString& cmd);
private slots: private slots:
void on_buttonBox_accepted(); void on_buttonBox_accepted();
}; };

@ -26,7 +26,7 @@ private:
Ui::MF_Sim_simDialog *ui; Ui::MF_Sim_simDialog *ui;
int cardType; int cardType;
signals: signals:
void sendCMD(QString cmd); void sendCMD(const QString& cmd);
private slots: private slots:
void on_buttonBox_accepted(); void on_buttonBox_accepted();
}; };

@ -3,7 +3,8 @@
#include <QDialog> #include <QDialog>
namespace Ui { namespace Ui
{
class MF_UID_parameterDialog; class MF_UID_parameterDialog;
} }
@ -18,7 +19,7 @@ public:
private: private:
Ui::MF_UID_parameterDialog *ui; Ui::MF_UID_parameterDialog *ui;
signals: signals:
void sendCMD(QString cmd); void sendCMD(const QString& cmd);
private slots: private slots:
void on_buttonBox_accepted(); void on_buttonBox_accepted();
}; };

Loading…
Cancel
Save