void PrintDialog::printPackets(QPrinter *printer, bool in_preview) { QPainter painter; if (!printer) return; page_pos_ = printer->pageRect().top(); in_preview_ = in_preview; /* Fill in our print args */ print_args_.format = PR_FMT_TEXT; print_args_.print_summary = pd_ui_->formatGroupBox->summaryEnabled(); print_args_.print_hex = pd_ui_->formatGroupBox->bytesEnabled(); print_args_.print_formfeed = pd_ui_->formFeedCheckBox->isChecked(); print_args_.print_dissections = print_dissections_none; if (pd_ui_->formatGroupBox->detailsEnabled()) { if (pd_ui_->formatGroupBox->allCollapsedEnabled()) print_args_.print_dissections = print_dissections_collapsed; else if (pd_ui_->formatGroupBox->asDisplayedEnabled()) print_args_.print_dissections = print_dissections_as_displayed; else if (pd_ui_->formatGroupBox->allExpandedEnabled()) print_args_.print_dissections = print_dissections_expanded; } // This should be identical to printer_. However, the QPrintPreviewWidget docs // tell us to draw on the printer handed to us by the paintRequested() signal. cur_printer_ = printer; cur_painter_ = &painter; if (!painter.begin(printer)) { QMessageBox::warning(this, tr("Print Error"), QString(tr("Unable to print to %1.")).arg(printer_.printerName()), QMessageBox::Ok); close(); } // cf_print_packets updates the progress bar which in turn calls // WiresharkApplication::processEvents(), which can make the preview trip // over itself. preview_->setUpdatesEnabled(false); cf_print_packets(cap_file_, &print_args_); preview_->setUpdatesEnabled(true); cur_printer_ = NULL; cur_painter_ = NULL; painter.end(); }
void PrintDialog::printPackets(QPrinter *printer, bool in_preview) { QPainter painter; if (!printer) return; page_pos_ = printer->pageRect().top(); in_preview_ = in_preview; /* Fill in our print args */ print_args_.format = PR_FMT_TEXT; print_args_.print_summary = pd_ui_->formatGroupBox->summaryEnabled(); print_args_.print_hex = pd_ui_->formatGroupBox->bytesEnabled(); print_args_.print_formfeed = pd_ui_->formFeedCheckBox->isChecked(); print_args_.print_dissections = print_dissections_none; if (pd_ui_->formatGroupBox->detailsEnabled()) { if (pd_ui_->formatGroupBox->allCollapsedEnabled()) print_args_.print_dissections = print_dissections_collapsed; else if (pd_ui_->formatGroupBox->asDisplayedEnabled()) print_args_.print_dissections = print_dissections_as_displayed; else if (pd_ui_->formatGroupBox->allExpandedEnabled()) print_args_.print_dissections = print_dissections_expanded; } // This should be identical to printer_. However, the QPrintPreviewWidget docs // tell us to draw on the printer handed to us by the paintRequested() signal. cur_printer_ = printer; cur_painter_ = &painter; if (!painter.begin(printer)) { QMessageBox::warning(this, tr("Print Error"), QString(tr("Unable to print to %1.")).arg(printer_.printerName()), QMessageBox::Ok); close(); } // Don't show a progress bar if we're previewing; if it takes a // significant amount of time to generate a preview of the first // page, We Have A Real Problem cf_print_packets(cap_file_, &print_args_, in_preview ? FALSE : TRUE); cur_printer_ = NULL; cur_painter_ = NULL; painter.end(); }
int ExportDissectionDialog::exec() { #if !defined(Q_OS_WIN) int retval; if (!cap_file_) return QDialog::Rejected; retval = QFileDialog::exec(); if (retval == QDialog::Accepted && selectedFiles().length() > 0) { cf_print_status_t status; QString file_name = selectedFiles()[0]; /* Fill in our print (and export) args */ print_args_.file = file_name.toUtf8().data(); print_args_.format = PR_FMT_TEXT; print_args_.to_file = TRUE; print_args_.cmd = NULL; print_args_.print_summary = TRUE; print_args_.print_dissections = print_dissections_as_displayed; print_args_.print_hex = FALSE; print_args_.print_formfeed = FALSE; switch (export_type_) { case export_type_text: /* Text */ print_args_.print_summary = packet_format_group_box_.summaryEnabled(); print_args_.print_dissections = print_dissections_none; if (packet_format_group_box_.detailsEnabled()) { if (packet_format_group_box_.allCollapsedEnabled()) print_args_.print_dissections = print_dissections_collapsed; else if (packet_format_group_box_.asDisplayedEnabled()) print_args_.print_dissections = print_dissections_as_displayed; else if (packet_format_group_box_.allExpandedEnabled()) print_args_.print_dissections = print_dissections_expanded; } print_args_.print_hex = packet_format_group_box_.bytesEnabled(); print_args_.stream = print_stream_text_new(TRUE, print_args_.file); if (print_args_.stream == NULL) { open_failure_alert_box(print_args_.file, errno, TRUE); return QDialog::Rejected; } status = cf_print_packets(cap_file_, &print_args_); break; case export_type_csv: /* CSV */ status = cf_write_csv_packets(cap_file_, &print_args_); break; case export_type_carrays: /* C Arrays */ status = cf_write_carrays_packets(cap_file_, &print_args_); break; case export_type_psml: /* PSML */ status = cf_write_psml_packets(cap_file_, &print_args_); break; case export_type_pdml: /* PDML */ status = cf_write_pdml_packets(cap_file_, &print_args_); break; default: return QDialog::Rejected; } switch (status) { case CF_PRINT_OK: break; case CF_PRINT_OPEN_ERROR: open_failure_alert_box(print_args_.file, errno, TRUE); break; case CF_PRINT_WRITE_ERROR: write_failure_alert_box(print_args_.file, errno); break; } if (selectedFiles().length() > 0) { gchar *dirname; /* Save the directory name for future file dialogs. */ dirname = get_dirname(print_args_.file); /* Overwrites file_name data */ set_last_open_dir(dirname); } } return retval; #else // Q_OS_WIN win32_export_file(parentWidget()->effectiveWinId(), cap_file_, export_type_); return QDialog::Accepted; #endif // Q_OS_WIN }