Exemplo n.º 1
0
void DownloadManager::save()
{
    QString path = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/";
    QDir dir;
    if(!dir.mkpath(path))
    {
        return;
    }
    QFile file(path + "downloads");
    if(!file.open(QIODevice::WriteOnly))
    {
        return;
    }
    QByteArray array;
    for(int i = count() - 1; i >= 0; i--)
    {
        DownloadItem * item = m_items.at(i);
        if(!item->isFinished())
        {
            array += item->from().toString().toUtf8();
            array += "\n";
            array += item->to().toString().toUtf8();
            array += "\n";
        }
    }
    file.write(array);
    file.close();
}