postoperation::postoperation(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::postoperation)
{
    ui->setupUi(this);

    //
    ui->pbPost->setFocusPolicy(Qt::NoFocus);//设置按钮无焦点
    ui->pbSearch->setFocusPolicy(Qt::NoFocus);//设置按钮无焦点
    ui->pbReturn->setFocusPolicy(Qt::NoFocus);//设置按钮无焦点
    ui->pbsendfile->setFocusPolicy(Qt::NoFocus);//设置按钮无焦点

    //IP
    localIpStr = getIp();
    ui->label_ipaddress->setText(localIpStr);

    //
    loadSize = 4*1024;
    totalBytes = 0;
    bytesWritten = 0;
    bytesToWrite = 0;
    tcpClient = new QTcpSocket(this);
    connect(tcpClient,SIGNAL(connected()),this,SLOT(startTransfer()));
    //当连接服务器成功时,发出connected()信号,我们开始传送文件
    connect(tcpClient,SIGNAL(bytesWritten(qint64)),this,SLOT(updateClientProgress(qint64)));
    //当有数据发送成功时,我们更新进度条
    connect(tcpClient,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(displayError(QAbstractSocket::SocketError)));

}
Ejemplo n.º 2
0
Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
{
    clientProgressBar = new QProgressBar;
    clientStatusLabel = new QLabel(tr("Client ready"));
    serverProgressBar = new QProgressBar;
    serverStatusLabel = new QLabel(tr("Server ready"));

#ifdef Q_OS_SYMBIAN
    QMenu *menu = new QMenu(this);

    QAction *optionsAction = new QAction(tr("Options"), this);
    optionsAction->setSoftKeyRole(QAction::PositiveSoftKey);
    optionsAction->setMenu(menu);
    addAction(optionsAction);

    startAction = menu->addAction(tr("Start"), this, SLOT(start()));

    quitAction = new QAction(tr("Exit"), this);
    quitAction->setSoftKeyRole(QAction::NegativeSoftKey);
    addAction(quitAction);

    connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
#else
    startButton = new QPushButton(tr("&Start"));
    quitButton = new QPushButton(tr("&Quit"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(startButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);

    connect(startButton, SIGNAL(clicked()), this, SLOT(start()));
    connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
#endif
    connect(&tcpServer, SIGNAL(newConnection()),
            this, SLOT(acceptConnection()));
    connect(&tcpClient, SIGNAL(connected()), this, SLOT(startTransfer()));
    connect(&tcpClient, SIGNAL(bytesWritten(qint64)),
            this, SLOT(updateClientProgress(qint64)));
    connect(&tcpClient, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(displayError(QAbstractSocket::SocketError)));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(clientProgressBar);
    mainLayout->addWidget(clientStatusLabel);
    mainLayout->addWidget(serverProgressBar);
    mainLayout->addWidget(serverStatusLabel);
    mainLayout->addStretch(1);
    mainLayout->addSpacing(10);
#ifndef Q_OS_SYMBIAN
    mainLayout->addWidget(buttonBox);
#endif
    setLayout(mainLayout);

    setWindowTitle(tr("Loopback"));
}
Ejemplo n.º 3
0
Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    //! initialisation of the parameter concern about the network environment
    networkEnvironment = new ccissNetworkEnvironment();
    networkEnvironment->init("self", 12345);
    networkEnvironment->init("piss", 10703, "127.0.0.1");
    //! create tcp server to wait for the connexion from igss_platform part
    server = new ccissServer(networkEnvironment);
    //! create tcp client to connect igss_platform
    ccissToPiss = new ccissClient(networkEnvironment);

//    QDateTime current_date_time = QDateTime::currentDateTime();
//    QString CurrentTime = current_date_time.toString("yyyy-MM-dd hh:mm:ss ddd");
//    qDebug()<<"Data out CurrentTime"<<CurrentTime<<"size"<<CurrentTime.size()<<"sizeof(quint16) size"<<sizeof(quint16);

    tcpServer = new QTcpServer();
    client = new QTcpSocket();

    this->constructIHM();
    this->setConnections();

    loadSize = 4*1024;
    totalBytes = 0;
    bytesWritten = 0;
    bytesToWrite = 0;
    fileSendReady = false;
    msgSendReady = false;
    tcpClient = new QTcpSocket(this);

    connect(tcpClient,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(displayError(QAbstractSocket::SocketError)));
    this->sendButton->setEnabled(false);
//    this->hostLineEdit->setText("127.0.0.1");
//    this->portLineEdit->setText("8888");

    connect(tcpClient,SIGNAL(connected()),this,SLOT(startTransferFile()));
    //当连接服务器成功时,发出connected()信号,我们开始传送文件
    connect(tcpClient,SIGNAL(connected()),this,SLOT(startTransferMsg()));
    //当连接服务器成功时,发出connected()信号,我们开始传送消息
    connect(tcpClient,SIGNAL(bytesWritten(qint64)),this,SLOT(updateClientProgress(qint64)));
    //当有数据发送成功时,我们更新进度条
}
int postoperation::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: send(); break;
        case 1: startTransfer(); break;
        case 2: displayError((*reinterpret_cast< QAbstractSocket::SocketError(*)>(_a[1]))); break;
        case 3: updateClientProgress((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 4: on_pbReturn_clicked(); break;
        case 5: on_pbPost_clicked(); break;
        case 6: on_pbSearch_clicked(); break;
        case 7: on_pbsendfile_clicked(); break;
        default: ;
        }
        _id -= 8;
    }
    return _id;
}
Ejemplo n.º 5
0
Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
{
    clientProgressBar = new QProgressBar;
    clientStatusLabel = new QLabel(tr("Client ready"));
    serverProgressBar = new QProgressBar;
    serverStatusLabel = new QLabel(tr("Server ready"));

    startButton = new QPushButton(tr("&Start"));
    quitButton = new QPushButton(tr("&Quit"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(startButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);

    connect(startButton, SIGNAL(clicked()), this, SLOT(start()));
    connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
    connect(&tcpServer, SIGNAL(newConnection()),
            this, SLOT(acceptConnection()));
    connect(&tcpClient, SIGNAL(connected()), this, SLOT(startTransfer()));
    connect(&tcpClient, SIGNAL(bytesWritten(qint64)),
            this, SLOT(updateClientProgress(qint64)));
    connect(&tcpClient, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(displayError(QAbstractSocket::SocketError)));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(clientProgressBar);
    mainLayout->addWidget(clientStatusLabel);
    mainLayout->addWidget(serverProgressBar);
    mainLayout->addWidget(serverStatusLabel);
    mainLayout->addStretch(1);
    mainLayout->addSpacing(10);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);

    setWindowTitle(tr("Loopback"));
}