-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathairbase.cpp
69 lines (57 loc) · 1.93 KB
/
airbase.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "airbase.h"
#include "ui_airbase.h"
#include"Fregister.h"
AirBase::AirBase(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::AirBase)
{
airSetting=new QSettings("conf.ini",QSettings::IniFormat);
ui->setupUi(this);
if(airSetting->value("firstLaunch").isNull())
{
airSetting->setValue("Path",QFileDialog::getExistingDirectory());
airSetting->setValue("firstLaunch","false");
Fregister *a=new Fregister();
a->show();
}
CtS=new TcpConnection(this);
CtS->tcpClient = new QTcpSocket(this);
//connect(CtS->tcpClient,SIGNAL(bytesWritten(qint64)),CtS,SLOT(updateClientProgress(qint64)));
connect(CtS->tcpClient,SIGNAL(error(QAbstractSocket::SocketError)),CtS,SLOT(displayError(QAbstractSocket::SocketError)));
connect(CtS->tcpClient,SIGNAL(readyRead()),CtS,SLOT(reciveData()));
//在这里添加下载文件的信号槽,在TcpConnection里实现
}
AirBase::~AirBase()
{
delete ui;
}
void AirBase::on_upload_clicked()
{
CtS->startUpload(QFileDialog::getOpenFileName(this));
}
void AirBase::on_connect_clicked()
{
ui->hostLineEdit->setText("127.0.0.1");
ui->portLineEdit->setText("6666");
CtS->tcpClient->connectToHost(QHostAddress(ui->hostLineEdit->text()),ui->portLineEdit->text().toInt());//连接
CtS->startUpload("./userDiscern");
}
void AirBase::on_sync_clicked()
{
createSyncFile();
CtS->startUpload("./temp/sync");
}
void AirBase::createSyncFile()
{
QString fileSysPath=airSetting->value("Path").toString();
QDir systemWatcher(fileSysPath);
QStringList fileSysDir=systemWatcher.entryList();
QFile fileMaker("./temp/sync");
fileMaker.open(QIODevice::ReadWrite);
for(int i=0;i<fileSysDir.size();i++)
{
fileMaker.write(fileSysDir[i].toStdString().c_str(),fileSysDir[i].size());
fileMaker.write("\n",1);
}
fileMaker.close();
}