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