Esempio n. 1
0
bool 
LocalFileStore::writeFile(QByteArray &data, QString remotename)
{

    // is the path set ?
    QString path = appsettings->cvalue(context->athlete->cyclist, GC_NETWORKFILESTORE_FOLDER, "").toString();
    if (path == "") {
        emit writeComplete("", tr("You must define a network folder first"));  // required for single upload to get to an end
        return false;
    };

    // open the path
    QDir current_path = QDir(path);
    if (!current_path.exists()) {
        emit writeComplete("", tr("Write to folder %1 failed").arg(path));  // required for single upload to get to an end
        return false;
    };

    QFile file(path+"/"+remotename);
    if (file.open(QIODevice::WriteOnly) ) {
        file.write(data);
        file.close();
    } else {
        file.close();
        emit writeComplete("", tr("Write to folder %1 failed").arg(path));  // required for single upload to get to an end
        return false;
    };

    emit writeComplete("", tr("Completed."));

    return true;
}
Esempio n. 2
0
FileStoreUploadDialog::FileStoreUploadDialog(QWidget *parent, FileStore *store, RideItem *item) : QDialog(parent), store(store), item(item)
{
    // get a compressed version
    store->compressRide(item->ride(), data, QFileInfo(item->fileName).baseName() + ".json");

    // setup the gui!
    QVBoxLayout *layout = new QVBoxLayout(this);
    info = new QLabel(QString(tr("Uploading %1 bytes...")).arg(data.size()));
    layout->addWidget(info);

    progress = new QProgressBar(this);
    progress->setMaximum(0);
    progress->setValue(0);
    layout->addWidget(progress);

    okcancel = new QPushButton(tr("Cancel"));
    QHBoxLayout *buttons = new QHBoxLayout;
    buttons->addStretch();
    buttons->addWidget(okcancel);
    layout->addLayout(buttons);

    // get notification when done
    connect(store, SIGNAL(writeComplete(QString,QString)), this, SLOT(completed(QString,QString)));

    // ok, so now we can kickoff the upload
    store->writeFile(data, QFileInfo(item->fileName).baseName() + ".json.zip");
}
CntSimContactSaveRequest::CntSimContactSaveRequest(CntSymbianSimEngine *engine, QContactSaveRequest *req)
    :CntAbstractSimRequest(engine, req)
{
    connect( simStore(), SIGNAL(writeComplete(QContact, QContactManager::Error)),
        this, SLOT(writeComplete(QContact, QContactManager::Error)), Qt::QueuedConnection );
}