Add $Id$, arrange that it's expanded, use native line endings.
[metze/wireshark/wip.git] / ui / qt / summary_dialog.cpp
1 /* summary_dialog.cpp
2  *
3  * $Id$
4  *
5  * GSoC 2013 - QtShark
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26
27 #include "summary_dialog.h"
28 #include "ui_summary_dialog.h"
29
30 #include "wireshark_application.h"
31
32 #include <QtGui>
33 #include <QPushButton>
34
35 SummaryDialog::SummaryDialog(QWidget *parent) :
36     QDialog(parent),
37     ui(new Ui::SummaryDialog)
38 {
39     ui->setupUi(this);
40
41     ui->tbDisplay->horizontalHeader()->setVisible(true);
42
43     /* set column widths */
44     ui->tbInterfaces->setColumnWidth(0, 305);
45     ui->tbInterfaces->setColumnWidth(1, 110);
46     ui->tbInterfaces->setColumnWidth(2, 90);
47 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
48     ui->tbInterfaces->horizontalHeader()->setResizeMode(3, QHeaderView::Stretch);
49 #else
50     ui->tbInterfaces->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch);
51 #endif
52     ui->tbInterfaces->setColumnWidth(4, 160);
53
54     ui->tbDisplay->setColumnWidth(0, 265);
55 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
56     ui->tbDisplay->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
57     ui->tbDisplay->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
58     ui->tbDisplay->horizontalHeader()->setResizeMode(3, QHeaderView::Stretch);
59 #else
60     ui->tbDisplay->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
61     ui->tbDisplay->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
62     ui->tbDisplay->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch);
63 #endif
64     this->setFixedSize(this->size());
65
66     connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(SaveComment()));
67     connect(ui->buttonBox, SIGNAL(helpRequested()), this, SLOT(HelpButton()));
68
69     bRefresh = ui->buttonBox->addButton(tr("Refresh"), QDialogButtonBox::ActionRole);
70     connect(bRefresh, SIGNAL(clicked()), this, SLOT(RefreshData()));
71
72     bCopyComment = ui->buttonBox->addButton(tr("Copy To Clipboard"), QDialogButtonBox::ActionRole);
73     connect(bCopyComment, SIGNAL(clicked()), this, SLOT(CopyComment()));
74 }
75
76 /*
77  *            Slots
78  **/
79
80 void SummaryDialog::RefreshData()
81 {
82     UpdateValues();
83 }
84
85 void SummaryDialog::SaveComment()
86 {
87     if (cfile.filename != NULL)
88     {
89         if (wtap_dump_can_write(cfile.linktypes, WTAP_COMMENT_PER_SECTION))
90         {
91             gchar *str = g_strdup((gchar*)ui->teCFComments->toPlainText().toStdString().c_str());
92             cf_update_capture_comment(&cfile, str);
93             emit captureCommentChanged();
94         }
95     }
96 }
97
98 void SummaryDialog::HelpButton()
99 {
100     wsApp->helpTopicAction(HELP_STATS_SUMMARY_DIALOG);
101 }
102
103 void SummaryDialog::CopyComment()
104 {
105     QClipboard *clipboard = QApplication::clipboard();
106
107     clipboard->setText(SummaryToString());
108 }
109
110 void SummaryDialog::on_tabWidget_currentChanged(int index)
111 {
112     // if we are showing the comment summary tab, we update it with new values
113     if (index == 2)
114     {
115         UpdateValues();
116         ui->pteCommentSummary->clear();
117         ui->pteCommentSummary->insertPlainText(SummaryToString());
118     }
119 }
120
121
122 /**/
123
124 QString SummaryDialog::SummaryToString()
125 {
126     UpdateValues();
127
128     QString summaryStr;
129     QTextStream out(&summaryStr);
130
131     out << tr("Summary created by Wireshark %1\n\n").arg(wireshark_svnversion);
132
133     // File Section
134     out << tr("File: \n");
135     out << "\t" << tr("Name:\t\t%1\n").arg(summary_.filename);
136     out << "\t" << tr("Length:\t\t%1 bytes\n").arg(summary_.file_length);
137     out << "\t" << tr("Format:\t\t%1%2\n")
138            .arg(wtap_file_type_string(summary_.file_type))
139            .arg(summary_.iscompressed? tr(" (gzip compressed)") : "");
140     out << "\t" << tr("Encapsulation:\t\t%1\n").arg(ui->lEncapsulation->text());
141
142     out << "\n\n";
143
144     // Time Section
145     out << tr("Time:\n");
146     if (summary_.packet_count_ts == summary_.packet_count &&
147             summary_.packet_count >= 1)
148     {
149
150         // start time
151         out << "\t" << tr("First packet:\t\t%1\n").arg(ui->lFirstPacket->text());
152
153         // stop time
154         out << "\t" << tr("Last packet:\t\t%1\n").arg(ui->lLastPacket->text());
155
156         // elapsed seconds (capture duration)
157         if (summary_.packet_count_ts >= 2) {
158             out << "\t" << tr("Elapsed:\t\t%1\n").arg(ui->lElapsed->text());
159         }
160
161     }
162     out << "\n\n";
163
164     // Capture Section
165     out << tr("Capture:\n");
166
167 //    // capture HW
168 //    if (summary_.shb_hardware){
169 //        out << INDENT << tr("Capture HW: %1\n").arg(ui_->captureHWLabel->text());
170 //    }
171     // capture OS
172     if (summary_.shb_os)
173     {
174         out << "\t" << tr("OS:\t%1\n").arg(ui->lOS->text());
175     }
176     // capture application
177     if (summary_.shb_user_appl)
178     {
179         out << "\t" << tr("Capture application:\t%1\n").arg(ui->lCaptureApp->text());
180     }
181
182     out << "\n";
183
184     // capture interfaces info
185     for (int i = 0; i < ui->tbInterfaces->rowCount(); i++)
186     {
187         out << "\t" << ui->tbInterfaces->item(i,0)->text() << "\n";
188         out << "\t" << "\t" << tr("Dropped packets:\t%1\n")
189                .arg(ui->tbInterfaces->item(i,1)->text());
190         out << "\t" << "\t" << tr("Capture filter:\t\t%1\n")
191                .arg(ui->tbInterfaces->item(i,2)->text());
192         out << "\t" << "\t" << tr("Link type:\t\t%1\n")
193                .arg(ui->tbInterfaces->item(i,3)->text());
194         out << "\t" << "\t" << tr("Packet size limit:\t%1\n")
195                .arg(ui->tbInterfaces->item(i,4)->text());
196     }
197
198     out << "\n\n";
199
200     // Statistics Section
201     out << tr("Statistics:\n");
202     for (int i = 0; i < ui->tbDisplay->rowCount(); i++)
203     {
204         out << "\t" << tr("%1:\t%2")
205                .arg(ui->tbDisplay->item(i,0)->text())
206                .arg(ui->tbDisplay->item(i,1)->text());
207         out << "\n";
208     }
209
210     out << "\n\n";
211
212     //Capture Comments Section - reads from GUI buffer
213     if(ui->teCFComments->isEnabled()
214             && (!ui->teCFComments->toPlainText().isEmpty()))
215     {
216         out << tr("Capture File Comments:\n");
217         out << ui->teCFComments->toPlainText() << endl;
218     }
219
220     return summaryStr;
221 }
222
223 QString SummaryDialog::TimeToString(time_t ti_time)
224 {
225     struct tm *ti_tm;
226     QString str;
227
228     ti_tm = localtime(&ti_time);
229     if (ti_tm == NULL)
230     {
231         str = tr("Not representable");
232     }
233     else
234     {
235         str = str.sprintf("%04d-%02d-%02d %02d:%02d:%02d",
236                           ti_tm->tm_year + 1900,
237                           ti_tm->tm_mon + 1,
238                           ti_tm->tm_mday,
239                           ti_tm->tm_hour,
240                           ti_tm->tm_min,
241                           ti_tm->tm_sec);
242     }
243     return str;
244 }
245
246
247
248 void SummaryDialog::UpdateValues()
249 {
250     QString output;
251     iface_options iface;
252
253     uint i;
254
255     double        seconds = 0.0;
256     double        disp_seconds = 0.0;
257     double        marked_seconds = 0.0;
258
259
260     memset(&summary_, 0, sizeof(summary_tally));
261
262
263     /* initial computations */
264     summary_fill_in(&cfile, &summary_);
265 #ifdef HAVE_LIBPCAP
266     summary_fill_in_capture(&cfile, &global_capture_opts, &summary_);
267 #endif
268
269     seconds = summary_.stop_time - summary_.start_time;
270     disp_seconds = summary_.filtered_stop - summary_.filtered_start;
271     marked_seconds = summary_.marked_stop - summary_.marked_start;
272
273
274     /*
275      *  File groupbox
276      * */
277
278     /* setting the filename */
279     ui->lFilename->setText(summary_.filename);
280
281     /* setting the length of the file */
282     ui->lLength->setText(QString(tr("%1 bytes (%2 Mbytes)")).arg((ulong)summary_.file_length).arg((float)summary_.file_length/1048576));
283
284     /* format */
285     ui->lFormat->setText(QString("%1%2").arg(wtap_file_type_string(summary_.file_type), summary_.iscompressed? tr(" (gzip compressed)") : ""));
286
287     /* encapsulation */
288     if (summary_.file_encap_type == WTAP_ENCAP_PER_PACKET)
289     {
290         for (i = 0; i < summary_.packet_encap_types->len; i++)
291         {
292             output = QString(wtap_encap_string(g_array_index(summary_.packet_encap_types, int, i)));
293         }
294     }
295     else
296     {
297         output = QString(wtap_encap_string(summary_.file_encap_type));
298     }
299
300     ui->lEncapsulation->setText(output);
301
302     /*
303      *  Time groupbox
304      * */
305
306     /* First packet and Last packet */
307
308     ui->lFirstPacket->setText(TimeToString((time_t)summary_.start_time));
309     ui->lLastPacket->setText(TimeToString((time_t)summary_.stop_time));
310
311     /*
312          * We must have at least two time-stamped packets for the elapsed time
313          * to be valid.
314          */
315     if (summary_.packet_count_ts >= 2)
316     {
317         /* elapsed seconds */
318         uint elapsed_time = (unsigned int)summary_.elapsed_time;
319         if(elapsed_time/86400)
320         {
321             output = output.sprintf("%02u days %02u:%02u:%02u", elapsed_time/86400,
322                                 elapsed_time%86400/3600,
323                                 elapsed_time%3600/60,
324                                 elapsed_time%60);
325         }
326         else
327         {
328             output = output.sprintf("%02u:%02u:%02u", elapsed_time%86400/3600,
329                                 elapsed_time%3600/60,
330                                 elapsed_time%60);
331         }
332         ui->lElapsed->setText(output);
333     }
334
335     /*============
336      *  Capture groupbox
337      *============ */
338
339     if (summary_.shb_os)
340     {
341         ui->lOS->setText(summary_.shb_os);
342     }
343
344     if (summary_.shb_user_appl)
345     {
346         ui->lCaptureApp->setText(summary_.shb_user_appl);
347     }
348
349     if (wtap_dump_can_write(cfile.linktypes, WTAP_COMMENT_PER_SECTION))
350     {
351         ui->teCFComments->setText(summary_.opt_comment);
352     }
353
354     /*============
355      *  Interfaces table
356      *============ */
357
358     ui->tbInterfaces->setRowCount(0);
359
360     for (i = 0; i < summary_.ifaces->len; i++)
361     {
362         ui->tbInterfaces->setRowCount(ui->tbInterfaces->rowCount() + 1);
363         iface = g_array_index(summary_.ifaces, iface_options, i);
364
365         /* interface */
366         if (iface.descr)
367         {
368             output = QString(iface.descr);
369         }
370
371         else if (iface.name)
372         {
373             output = QString(iface.name);
374         }
375
376         else
377         {
378             output = QString(tr("unknown"));
379         }
380
381         ui->tbInterfaces->setItem(ui->tbInterfaces->rowCount()-1, 0, new QTableWidgetItem(output));
382
383
384
385         /* Dropped count */
386         if (iface.drops_known)
387         {
388             output = QString("%1 (%2 %)").arg(iface.drops).arg(QString::number(
389                      /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
390                      summary_.packet_count ?(100.0 * (gint64)iface.drops)/summary_.packet_count : 0.0f, 'g', 3));
391         }
392         else
393         {
394             output = QString(tr("Unknown"));
395         }
396         ui->tbInterfaces->setItem(ui->tbInterfaces->rowCount()-1, 1, new QTableWidgetItem(output));
397
398
399
400         /* Capture filter */
401         if (iface.cfilter && iface.cfilter[0] != '\0')
402         {
403             output = output.sprintf("%s", iface.cfilter);
404         }
405         else
406         {
407             if (iface.name)
408             {
409                 output = QString(tr("none"));
410             }
411             else
412             {
413                 output = QString(tr("unknown"));
414             }
415         }
416         ui->tbInterfaces->setItem(ui->tbInterfaces->rowCount()-1, 2, new QTableWidgetItem(output));
417
418         ui->tbInterfaces->setItem(ui->tbInterfaces->rowCount()-1, 3, new QTableWidgetItem(wtap_encap_string(iface.encap_type)));
419
420         output = output.sprintf(tr("%u bytes").toStdString().c_str(), iface.snap);
421         ui->tbInterfaces->setItem(ui->tbInterfaces->rowCount()-1, 4, new QTableWidgetItem(output));
422
423     }
424
425     /*============
426      *  Display table
427      *============ */
428
429     /* Display filter */
430     if (summary_.dfilter)
431     {
432
433         output = QString(summary_.dfilter);
434     }
435     else
436     {
437         output = QString(tr("none"));
438     }
439
440     ui->lDisplayFilter->setText(output);
441
442
443     /* Ignored packets */
444     output = output.sprintf("%i (%.3f%%)", summary_.ignored_count,
445                         summary_.packet_count ? (100.0 * summary_.ignored_count)/summary_.packet_count : 0.0);
446
447     ui->lIgnoredPackets->setText(output);
448
449
450
451     /* filling the display table*/
452     ui->tbDisplay->setRowCount(0);
453
454
455
456     /*
457      *            Packet count
458      **/
459
460     ui->tbDisplay->setRowCount(ui->tbDisplay->rowCount() + 1);
461     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 0, new QTableWidgetItem(tr("Packets")));
462
463     output = output.sprintf("%i", summary_.packet_count);
464     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 1, new QTableWidgetItem(output));
465
466     if (summary_.dfilter)
467     {
468         output = output.sprintf("%i (%.3f%%)", summary_.filtered_count,
469                             summary_.packet_count ?
470                                 (100.0 * summary_.filtered_count)/summary_.packet_count : 0.0);
471
472     }
473     else
474     {
475         output = output.sprintf("%i (100.000%%)", summary_.packet_count);
476     }
477     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 2, new QTableWidgetItem(output));
478
479
480     output = output.sprintf("%i (%.3f%%)", summary_.marked_count,
481                         summary_.packet_count ?
482                             (100.0 * summary_.marked_count)/summary_.packet_count : 0.0);
483     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 3, new QTableWidgetItem(output));
484
485     /*
486      *            Time between first and last
487      **/
488     ui->tbDisplay->setRowCount(ui->tbDisplay->rowCount() + 1);
489
490     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 0, new QTableWidgetItem(tr("Between first and last packet")));
491     if (seconds > 0)
492     {
493         output = output.sprintf(tr("%.3f sec").toStdString().c_str(), seconds);
494
495     }
496     else
497     {
498         output = QString("N/A");
499     }
500     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 1, new QTableWidgetItem(output));
501
502     /* Displayed packet count */
503     if (summary_.dfilter && disp_seconds > 0)
504     {
505         output = output.sprintf(tr("%.3f sec").toStdString().c_str(), disp_seconds);
506     }
507     else
508     {
509         output = QString("N/A");
510     }
511     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 2, new QTableWidgetItem(output));
512
513     /* Marked packet count */
514     if (summary_.marked_count && marked_seconds > 0)
515     {
516         output = output.sprintf(tr("%.3f sec").toStdString().c_str(), marked_seconds);
517     }
518     else
519     {
520         output = QString("N/A");
521     }
522     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 3, new QTableWidgetItem(output));
523
524
525
526     /*
527      *           Average packets per second
528      **/
529
530     ui->tbDisplay->setRowCount(ui->tbDisplay->rowCount() + 1);
531
532     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 0, new QTableWidgetItem(tr("Avg. packets/sec")));
533     if (seconds > 0)
534     {
535         output = output.sprintf("%.3f", summary_.packet_count/seconds);
536
537     }
538     else
539     {
540         output = QString("N/A");
541     }
542     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 1, new QTableWidgetItem(output));
543
544     /* Displayed packet count/sec */
545     if (summary_.dfilter && disp_seconds > 0)
546     {
547         output = output.sprintf("%.3f", summary_.filtered_count/disp_seconds);
548     }
549     else
550     {
551         output = QString("N/A");
552     }
553     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 2, new QTableWidgetItem(output));
554
555     /* Marked packet count/sec */
556     if (summary_.marked_count && marked_seconds > 0)
557     {
558         output = output.sprintf("%.3f", summary_.marked_count/marked_seconds);
559     }
560     else
561     {
562         output = QString("N/A");
563     }
564     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 3, new QTableWidgetItem(output));
565
566
567     /*
568      *          Average packet size
569      **/
570
571     ui->tbDisplay->setRowCount(ui->tbDisplay->rowCount() + 1);
572
573     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 0, new QTableWidgetItem(tr("Avg. packet size")));
574     if (summary_.packet_count > 1)
575     {
576         output = output.sprintf(tr("%.3f bytes").toStdString().c_str(),
577                             /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
578                             (float) ((gint64) summary_.bytes)/summary_.packet_count);
579
580     }
581     else
582     {
583         output = QString("N/A");
584     }
585     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 1, new QTableWidgetItem(output));
586
587
588     if (summary_.dfilter && summary_.filtered_count > 1)
589     {
590         output = output.sprintf(tr("%.3f bytes").toStdString().c_str(),
591                             /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
592                             (float) ((gint64) summary_.filtered_bytes)/summary_.filtered_count);
593     }
594     else
595     {
596         output = QString("N/A");
597     }
598     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 2, new QTableWidgetItem(output));
599
600
601     if (summary_.marked_count > 1)
602     {
603         output = output.sprintf(tr("%.3f bytes").toStdString().c_str(),
604                             /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
605                             (float) ((gint64) summary_.marked_bytes)/summary_.marked_count);
606     }
607     else
608     {
609         output = QString("N/A");
610     }
611     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 3, new QTableWidgetItem(output));
612
613
614     /*
615      *          Byte count
616      **/
617
618
619     ui->tbDisplay->setRowCount(ui->tbDisplay->rowCount() + 1);
620     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 0, new QTableWidgetItem(tr("Bytes")));
621
622
623     output = QString("%1").arg(summary_.bytes);
624
625     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 1, new QTableWidgetItem(output));
626
627     if (summary_.dfilter)
628     {
629         output = QString("%1 (%2%)").arg(summary_.filtered_bytes).arg(QString::number(
630                  /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
631                  summary_.bytes ?(100.0 * (gint64)summary_.filtered_bytes)/summary_.bytes : 0.0f, 'g', 3));
632
633     }
634     else
635     {
636         output = QString("%1 (100.000%)").arg(summary_.bytes);
637     }
638     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 2, new QTableWidgetItem(output));
639
640
641     if (summary_.marked_count)
642     {
643         output = QString("%1 (%2%)").arg(summary_.marked_bytes).arg(QString::number(
644                  /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
645                  summary_.bytes ?(100.0 * (gint64)summary_.marked_bytes)/summary_.bytes : 0.0f, 'g', 3));
646     }
647     else
648     {
649         output = QString("0 (0.000%)");
650     }
651     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 3, new QTableWidgetItem(output));
652
653
654
655
656     /*
657      *           Bytes per second
658      **/
659
660     ui->tbDisplay->setRowCount(ui->tbDisplay->rowCount() + 1);
661
662     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 0, new QTableWidgetItem(tr("Avg. bytes/sec")));
663     if (seconds > 0)
664     {
665         /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
666         output = output.sprintf("%.3f", ((gint64) summary_.bytes)/seconds);
667
668     }
669     else
670     {
671         output = QString("N/A");
672     }
673     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 1, new QTableWidgetItem(output));
674
675     /* Displayed packet count/sec */
676     if (summary_.dfilter && disp_seconds > 0)
677     {
678         /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
679         output = output.sprintf("%.3f", ((gint64) summary_.filtered_bytes)/disp_seconds);
680     }
681     else
682     {
683         output = QString("N/A");
684     }
685     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 2, new QTableWidgetItem(output));
686
687     /* Marked packet count/sec */
688     if (summary_.marked_count && marked_seconds > 0)
689     {
690         /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
691         output = output.sprintf("%.3f", ((gint64) summary_.marked_bytes)/marked_seconds);
692     }
693     else
694     {
695         output = QString("N/A");
696     }
697     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 3, new QTableWidgetItem(output));
698
699
700     /*
701      *           MBits per second
702      **/
703
704     ui->tbDisplay->setRowCount(ui->tbDisplay->rowCount() + 1);
705
706     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 0, new QTableWidgetItem(tr("Avg. MBit/sec")));
707     if (seconds > 0)
708     {
709         /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
710         output = output.sprintf("%.3f", ((gint64) summary_.bytes) * 8.0 / (seconds * 1000.0 * 1000.0));
711
712     }
713     else
714     {
715         output = QString("N/A");
716     }
717     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 1, new QTableWidgetItem(output));
718
719     /* Displayed packet count/sec */
720     if (summary_.dfilter && disp_seconds > 0)
721     {
722         /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
723         output = output.sprintf("%.3f", ((gint64) summary_.filtered_bytes) * 8.0 / (disp_seconds * 1000.0 * 1000.0));
724     }
725     else
726     {
727         output = QString("N/A");
728     }
729     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 2, new QTableWidgetItem(output));
730
731     /* Marked packet count/sec */
732     if (summary_.marked_count && marked_seconds > 0)
733     {
734         /* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
735         output = output.sprintf("%.3f", ((gint64) ((gint64) summary_.marked_bytes) * 8.0 / (marked_seconds * 1000.0 * 1000.0)));
736     }
737     else
738     {
739         output = QString("N/A");
740     }
741     ui->tbDisplay->setItem(ui->tbDisplay->rowCount()-1, 3, new QTableWidgetItem(output));
742
743
744 }
745
746 SummaryDialog::~SummaryDialog()
747 {
748     delete ui;
749 }
750
751 /*
752
753  * Editor modelines
754  *
755  * Local Variables:
756  * c-basic-offset: 4
757  * tab-width: 8
758  * indent-tabs-mode: nil
759  * End:
760  *
761  * ex: set shiftwidth=4 tabstop=8 expandtab:
762  * :indentSize=4:tabSize=8:noTabs=true:
763  */