コード例 #1
0
void ProfileManager::updateProfile(const QString &current, const QString &profile)
{
    if (current == profile) {
        return;
    }

    Updater::Version prof(profile);

    if (prof == Updater::Version("1.0.0")) {
        update100();
        return;
    }

    if (prof == Updater::Version("1.1.0") || prof == Updater::Version("1.1.5") || prof == Updater::Version("1.1.8")) {
        update118();
        return;
    }

    if (prof == Updater::Version("1.2.0")) {
        update120();
        return;
    }

    if (prof == Updater::Version("1.3.0") || prof == Updater::Version("1.3.1")) {
        update130();
        return;
    }

    if (prof >= Updater::Version("1.4.0") && prof <= Updater::Version("1.5.0")) {
        update140();
        return;
    }

    if (prof >= Updater::Version("1.6.0") && prof < Updater::Version("1.8.0")) {
        update160();
        return;
    }

    if (prof >= Updater::Version("1.8.0") && prof < Updater::Version("1.9.0")) {
        // do nothing
        return;
    }

    std::cout << "QupZilla: Incompatible profile version detected (" << qPrintable(profile) << "), overwriting profile data..." << std::endl;

    copyDataToProfile();
}
コード例 #2
0
void ProfileManager::update120()
{
    std::cout << "QupZilla: Upgrading profile version from 1.2.0..." << std::endl;

    connectDatabase();

    QSqlDatabase db = QSqlDatabase::database();
    db.transaction();

    // This is actually just renaming bookmarks.toolbar_position to bookmarks.position
    QSqlQuery query;
    query.exec("ALTER TABLE bookmarks RENAME TO tmp_bookmarks");
    query.exec("CREATE TABLE bookmarks (icon TEXT, folder TEXT, id INTEGER PRIMARY KEY, title VARCHAR(200), url VARCHAR(200), position NUMERIC)");
    query.exec("INSERT INTO bookmarks(icon, folder, id, title, url, position)"
               "SELECT icon, folder, id, title, url, toolbar_position FROM tmp_bookmarks");
    query.exec("DROP TABLE tmp_bookmarks");
    query.exec("CREATE INDEX bookmarksTitle ON bookmarks(title ASC)");
    query.exec("CREATE INDEX bookmarksUrl ON bookmarks(url ASC)");

    db.commit();

    update130();
}