-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
heyuanjie
committed
Jan 4, 2017
1 parent
20ea689
commit e49e2a5
Showing
30 changed files
with
2,844 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include "Modem.h" | ||
#include "ui_modem.h" | ||
|
||
#include "Ymodem.h" | ||
|
||
Modem::Modem(QWidget *parent) : | ||
QDialog(parent), | ||
ui(new Ui::Modem) | ||
{ | ||
ui->setupUi(this); | ||
|
||
ym = new Ymodem(this); | ||
connect(ym, &ym->showTransfer, this, &this->showTransfer); | ||
connect(ym, &ym->finished, this, &this->closed); | ||
} | ||
|
||
Modem::~Modem() | ||
{ | ||
delete ui; | ||
} | ||
|
||
void Modem::getFile(QString &name) | ||
{ | ||
name = filename; | ||
} | ||
|
||
void Modem::setFile(QString &name) | ||
{ | ||
filename = name; | ||
} | ||
|
||
void Modem::showTransfer(int total, int remain, float speed) | ||
{ | ||
float p; | ||
QString fmt; | ||
|
||
p = ((total - remain)/(float)total) * 100; | ||
fmt = fmt.fromLocal8Bit("%1%").arg(QString::number(p, 'f', 1)); | ||
ui->progress->setValue((int)p); | ||
ui->progress->setFormat(fmt); | ||
} | ||
|
||
void Modem::startTransfer(char type) | ||
{ | ||
show(); | ||
ym->start(); | ||
} | ||
|
||
void Modem::putData(const QByteArray &data) | ||
{ | ||
ym->put(data); | ||
} | ||
|
||
void Modem::showStatus(const char *s) | ||
{ | ||
ui->lbmsg->setText(s); | ||
} | ||
|
||
void Modem::closed() | ||
{ | ||
emit exitTransfer(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#ifndef MODEM_H | ||
#define MODEM_H | ||
|
||
#include <QDialog> | ||
|
||
namespace Ui { | ||
class Modem; | ||
} | ||
|
||
class Ymodem; | ||
|
||
class Modem : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit Modem(QWidget *parent = 0); | ||
~Modem(); | ||
|
||
void setFile(QString &name); | ||
void getFile(QString &name); | ||
void startTransfer(char type = 'C'); | ||
void showStatus(const char *s); | ||
|
||
public Q_SLOTS: | ||
void putData(const QByteArray &data); | ||
|
||
private Q_SLOTS: | ||
void showTransfer(int total, int remain, float speed); | ||
void closed(); | ||
|
||
Q_SIGNALS: | ||
void outData(const QByteArray &data); | ||
void exitTransfer(); | ||
|
||
private: | ||
Ui::Modem *ui; | ||
Ymodem *ym; | ||
QString filename; | ||
}; | ||
|
||
#endif // MODEM_H |
Oops, something went wrong.