Esempio n. 1
0
void ProfileDialog::on_deleteToolButton_clicked()
{
    QTreeWidgetItem *item = pd_ui_->profileTreeWidget->currentItem();

    if (item) {
        GList *fl_entry = VariantPointer<GList>::asPtr(item->data(0, Qt::UserRole));
        profile_def *profile = (profile_def *) fl_entry->data;
        if (profile->is_global || item->font(0).strikeOut()) {
            return;
        }
        if (profile->status == PROF_STAT_DEFAULT) {
            QFont ti_font = item->font(0);
            ti_font.setStrikeOut(true);
            item->setFont(0, ti_font);
            updateWidgets();
        } else {
            delete item;

            // Select the default
            pd_ui_->profileTreeWidget->setCurrentItem(pd_ui_->profileTreeWidget->topLevelItem(0));

            remove_from_profile_list(fl_entry);
        }
    }
}
Esempio n. 2
0
void ProfileDialog::on_buttonBox_accepted()
{
    gchar *err_msg;
    QTreeWidgetItem *default_item = pd_ui_->profileTreeWidget->topLevelItem(0);
    QTreeWidgetItem *item = pd_ui_->profileTreeWidget->currentItem();
    gchar *profile_name = NULL;
    bool write_recent = true;
    bool item_data_removed = false;

    if (default_item && default_item->font(0).strikeOut()) {
        // Reset Default profile.
        GList *fl_entry = VariantPointer<GList>::asPtr(default_item->data(0, Qt::UserRole));
        remove_from_profile_list(fl_entry);

        // Don't write recent file if leaving the Default profile after this has been reset.
        write_recent = !is_default_profile();

        // Don't fetch profile data if removed.
        item_data_removed = (item == default_item);
    }

    if (write_recent) {
        /* Get the current geometry, before writing it to disk */
        wsApp->emitAppSignal(WiresharkApplication::ProfileChanging);

        /* Write recent file for current profile now because
         * the profile may be renamed in apply_profile_changes() */
        write_profile_recent();
    }

    if ((err_msg = apply_profile_changes()) != NULL) {
        QMessageBox::critical(this, tr("Profile Error"),
                              err_msg,
                              QMessageBox::Ok);
        g_free(err_msg);
        return;
    }

    if (item && !item_data_removed) {
        profile_def *profile = (profile_def *) VariantPointer<GList>::asPtr(item->data(0, Qt::UserRole))->data;
        profile_name = profile->name;
    }

    if (profile_exists (profile_name, FALSE) || profile_exists (profile_name, TRUE)) {
        // The new profile exists, change.
        wsApp->setConfigurationProfile (profile_name, FALSE);
    } else if (!profile_exists (get_profile_name(), FALSE)) {
        // The new profile does not exist, and the previous profile has
        // been deleted.  Change to the default profile.
        wsApp->setConfigurationProfile (NULL, FALSE);
    }
}
Esempio n. 3
0
void ProfileDialog::on_deleteToolButton_clicked()
{
    QTreeWidgetItem *item = pd_ui_->profileTreeWidget->currentItem();

    if (item) {
        GList *fl_entry = item->data(0, Qt::UserRole).value<GList *>();
        profile_def *profile = (profile_def *) fl_entry->data;
        if (profile->is_global || profile->status == PROF_STAT_DEFAULT) {
            return;
        }
        remove_from_profile_list(fl_entry);
        delete item;

        // Select the default
        pd_ui_->profileTreeWidget->setCurrentItem(pd_ui_->profileTreeWidget->topLevelItem(0));
    }
}