示例#1
0
CommClient::CommClient(QObject* parent) :
    QObject(parent)
{
    QString path = QDir::homePath();
    path.append("/ISL_workspace/src/configISL.json");

    robotID = 0;

    if( !readConfigFile(path) ){
        qDebug()<< "Read Config File Failed!!!";
    }
    else
    {
       qDebug() << "robotID is: "<< robotID;
    }


    socket = new QTcpSocket(this);

    socket->setReadBufferSize(0);

    connect(socket,SIGNAL(readyRead()),this,SLOT(receiveData()));

    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displaySocketError(QAbstractSocket::SocketError)));

    qDebug() << "Client IP is: " << IP;

    socket->connectToHost(IP,4012);

    if(socket->waitForConnected(5000)){
        qDebug()<<"Connected";
    }
    else
    {
        qDebug()<<"Error timeout";
    }
}
示例#2
0
IRC_USE_NAMESPACE

MessageModel::MessageModel(IrcBuffer* buffer) : QAbstractListModel(buffer),
    m_badge(0), m_current(false), m_visible(false), m_separator(-1),
    m_highlights(0), m_buffer(buffer), m_formatter(new MessageFormatter(this))
{
    m_formatter->setStripNicks(true);
    m_formatter->setDetailed(false);
    m_formatter->setBuffer(buffer);
    m_formatter->setTimeStampFormat("");

    connect(buffer, SIGNAL(messageReceived(IrcMessage*)), this, SLOT(receive(IrcMessage*)));
    if (buffer->isSticky()) {
        IrcConnection* connection = buffer->connection();
        if (connection) {
            connect(connection, SIGNAL(secureError()), this, SLOT(displaySecureError()));
            connect(connection, SIGNAL(socketError(QAbstractSocket::SocketError)), this, SLOT(displaySocketError()));
        }
    }

    connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(countChanged()));
    connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(countChanged()));
    connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged()));
}