Example #1
0
void TCPServer::slotNewConnection ()
{
    qDebug() << "Got a new connection!!!!";
    m_clientConnection = m_server->nextPendingConnection();
    //Make sure the connection is deleted when it disconnects
    connect (m_clientConnection, SIGNAL(disconnected()), this, SLOT(slotDoneRecv()));
    connect (m_clientConnection, SIGNAL(readyRead()), this, SLOT(slotReadData()));
}
Example #2
0
void MyServer::incomingConnection(qintptr descriptor)
{
    socketClients *client = new socketClients(descriptor);                      // qDebug()<<"descriptor= "<<descriptor;
    connect(client,SIGNAL(disconnected(int)),this,SLOT(slotDisconnected(int)));
    connect(client,SIGNAL(readyRead(QByteArray)),this,SLOT(slotReadData(QByteArray)));
    clients.append(client);
    // 回送服务器端socketDescriptor值
    QByteArray *data = model.sendDescriptor(descriptor);
    client->getSocket()->write(*data);
    delete data;
}
Example #3
0
void toResultModel::fetchMore(const QModelIndex &parent)
{
    Q_UNUSED(parent);

    // sometimes the view calls this before the query has even
    // run. don't actually increase max until we've hit it.
    if (MaxRows < 0 || MaxRows <= Rows.size())
        MaxRows += MaxRowsToAdd;

    slotReadData();
}
Example #4
0
void toResultModel::slotFetchMore(toEventQuery*)
{
    if (ReadAll)
    {
        MaxRows = -1;
        slotReadData();
    }
    else if (Rows.size() < MaxRows)
    {
        QModelIndex ind;
        fetchMore(ind);
    }
}
void LoadImageFromUrl::startLoadImage (const QUrl &url)
{
  LOG4CPP_INFO_S ((*mainCat)) << "LoadImageFromUrl::startLoadImage url=" << url.toString ().toLatin1 ().data ();

  m_url = url;
  if (url.isLocalFile ()) {

    QFileInfo fileInfo (url.toLocalFile ());

    // Load local file. This is done synchronously
    QImage image;
    if (image.load (url.toLocalFile ())) {

      emit signalImportImage (fileInfo.fileName (),
                              image);

    } else {

      // Probably a bad file type

      QString message;
      QTextStream str (&message);

      str << tr ("Unable to load image from") << " " << url.toLocalFile ();

      QMessageBox::critical (&m_mainWindow,
                             engaugeWindowTitle(),
                             message,
                             QMessageBox::Ok);
    }

  } else {

    // Asynchronous read from url
    deallocate ();
    m_buffer = new QByteArray;
    QNetworkRequest request (url);
    m_reply = m_http.get (request);

    connect (m_reply, SIGNAL (readyRead()), this, SLOT (slotReadData()));
    connect (m_reply, SIGNAL (finished ()), this, SLOT (slotFinished ()));
  }
}