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