void MainWindow::FillTableSoft(QTableWidget* table, const AvailableSoftWare::SoftWareMap& soft) {
    AvailableSoftWare::SoftWareMap::const_iterator iter;
    table->setRowCount(0);
    for (iter = soft.begin(); iter != soft.end(); ++iter) {
        const QString& name = iter.key();
        const SoftWare& config = iter.value();

        int i = table->rowCount();
        table->insertRow(i);
        table->setItem(i, COLUMN_NAME, new QTableWidgetItem(name));
        table->setItem(i, COLUMN_CUR_VER, new QTableWidgetItem(config.m_CurVersion));
        if (config.m_AvailableVersion.size() == 1) {
            table->setItem(i, COLUMN_NEW_VER, new QTableWidgetItem(*(config.m_AvailableVersion.begin())));
        } else {
            QComboBox* pComboBox = new QComboBox(table);
            connect(pComboBox,
                    SIGNAL(currentIndexChanged(QString)),
                    this,
                    SLOT(OnComboBoxValueChanged(QString)));

            QList<QString> versionsList = config.m_AvailableVersion.toList();
            qSort(versionsList);

            for (QList<QString>::const_iterator iter = versionsList.begin();
                 iter != versionsList.end();
                 ++iter) {
                pComboBox->addItem(*iter);
            }
            pComboBox->setCurrentIndex(pComboBox->count() - 1);
            table->setCellWidget(i, COLUMN_NEW_VER, pComboBox);
        }
    }
    table->resizeRowsToContents();
}
void MainWindow::FillTableDependencies(QTableWidget* table, const AvailableSoftWare::SoftWareMap& soft) {
    AvailableSoftWare::SoftWareMap::const_iterator iter;
    table->setRowCount(0);
    for (iter = soft.begin(); iter != soft.end(); ++iter) {
        const QString& name = iter.key();
        const SoftWare& config = iter.value();

        int i = table->rowCount();
        table->insertRow(i);
        table->setItem(i, COLUMN_NAME, new QTableWidgetItem(name));
        if (config.m_CurVersion.isEmpty())
            table->setItem(i, COLUMN_CUR_VER, new QTableWidgetItem("Not installed"));
        else if (config.m_CurVersion == config.m_NewVersion)
            table->setItem(i, COLUMN_CUR_VER, new QTableWidgetItem("Installed latest"));
        else
            table->setItem(i, COLUMN_CUR_VER, new QTableWidgetItem("Installed not latest"));
    }
    table->resizeRowsToContents();
}
Beispiel #3
0
bool Installer::Update(AvailableSoftWare::SoftWareMap softMap, eAppType type, bool force /*= false*/) {
    AvailableSoftWare::SoftWareMap::const_iterator iter;
    for (iter = softMap.begin(); iter != softMap.end(); ++iter) {
        const QString& name = iter.key();
        const SoftWare& soft = iter.value();
        if (!soft.m_CurVersion.isEmpty() &&
            Settings::GetVersion(soft.m_CurVersion) != Settings::GetVersion(soft.m_NewVersion)) {
            if (force ||
                0 == QMessageBox::information(NULL,//this,
                                             tr("Update available"),
                                             tr("%1 update available.").arg(name),
                                             tr("Install"),
                                             tr("Cancel"))) {
                if (!Delete(name, type, force)) {
                    Logger::GetInstance()->AddLog(tr("Error update %1"));
                    return false;
                }
                Install(name, soft.m_NewVersion, type);
            }
        }
    }
    return true;
}
Beispiel #4
0
void Installer::FormatFromUpdate(AvailableSoftWare::SoftWareMap& softMap, const AppsConfig::AppMap& update) {
    for (AppsConfig::AppMap::const_iterator appIter = update.begin(); appIter != update.end(); ++appIter) {
        for (AppsConfig::AppVersion::const_iterator iter = appIter.value().begin();
             iter != appIter.value().end();
             ++iter) {
            const AppConfig& appConfig = iter.value();

            if (softMap.contains(appConfig.m_Name)) {
                softMap[appConfig.m_Name].m_AvailableVersion.insert(appConfig.m_Version);
            } else {
                SoftWare soft;
                soft.m_AvailableVersion.insert(appConfig.m_Version);
                softMap[appConfig.m_Name] = soft;
            }
            if (Settings::GetVersion(softMap[appConfig.m_Name].m_NewVersion) != Settings::GetVersion(appConfig.m_Version))
                softMap[appConfig.m_Name].m_NewVersion = appConfig.m_Version;
        }
    }
}