<commit_before>//-----------------------------------
// Copyright <NAME> 2013-2017
//-----------------------------------

#include "orbitsamplingreport.h"

#include <cassert>

#include "SamplingReport.h"
#include "orbitdataviewpanel.h"
#include "orbittreeview.h"
#include "ui_orbitsamplingreport.h"

//-----------------------------------------------------------------------------
OrbitSamplingReport::OrbitSamplingReport(QWidget* parent)
    : QWidget(parent), ui(new Ui::OrbitSamplingReport) {
  ui->setupUi(this);
  if (!m_SamplingReport || !m_SamplingReport->HasCallstacks()) {
    ui->NextCallstackButton->setEnabled(false);
    ui->NextCallstackButton->setStyleSheet(
        QString::fromUtf8("QPushButton:disabled{ color: gray }"));
    ui->PreviousCallstackButton->setEnabled(false);
    ui->PreviousCallstackButton->setStyleSheet(
        QString::fromUtf8("QPushButton:disabled{ color: gray }"));
  }

  QList<int> sizes;
  sizes.append(5000);
  sizes.append(5000);
  ui->splitter->setSizes(sizes);
}

//-----------------------------------------------------------------------------
OrbitSamplingReport::~OrbitSamplingReport() { delete ui; }

//-----------------------------------------------------------------------------
void OrbitSamplingReport::Initialize(DataView* callstack_data_view,
                                     std::shared_ptr<SamplingReport> report) {
  ui->CallstackTreeView->Initialize(
      callstack_data_view, SelectionType::kExtended, FontType::kDefault, false);
  m_SamplingReport = report;

  if (!report) return;

  m_SamplingReport->SetUiRefreshFunc([&]() { this->Refresh(); });

  for (SamplingReportDataView& report : report->GetThreadReports()) {
    QWidget* tab = new QWidget();
    tab->setObjectName(QStringLiteral("tab"));

    QGridLayout* gridLayout_2 = new QGridLayout(tab);
    gridLayout_2->setObjectName(QStringLiteral("gridLayout_2"));
    OrbitDataViewPanel* treeView = new OrbitDataViewPanel(tab);
    treeView->SetDataModel(&report);

    if (!report.IsSortingAllowed()) {
      treeView->GetTreeView()->setSortingEnabled(false);
    } else {
      int column = report.GetDefaultSortingColumn();
      Qt::SortOrder order = report.GetColumns()[column].initial_order ==
                                    DataView::SortingOrder::Ascending
                                ? Qt::AscendingOrder
                                : Qt::DescendingOrder;
      treeView->GetTreeView()->sortByColumn(column, order);
    }

    treeView->setObjectName(QStringLiteral("treeView"));
    gridLayout_2->addWidget(treeView, 0, 0, 1, 1);
    treeView->GetTreeView()->setSelectionMode(OrbitTreeView::ExtendedSelection);
    treeView->GetTreeView()->header()->resizeSections(
        QHeaderView::ResizeToContents);

    treeView->Link(ui->CallstackTreeView);

    QString threadName = QString::fromStdString(report.GetName());
    ui->tabWidget->addTab(tab, threadName);
  }
}<commit_msg>Rename var report in OrbitSamplingReport::Initialize, it shadows a parameter<commit_after>//-----------------------------------
// Copyright <NAME> 2013-2017
//-----------------------------------

#include "orbitsamplingreport.h"

#include <cassert>

#include "SamplingReport.h"
#include "orbitdataviewpanel.h"
#include "orbittreeview.h"
#include "ui_orbitsamplingreport.h"

//-----------------------------------------------------------------------------
OrbitSamplingReport::OrbitSamplingReport(QWidget* parent)
    : QWidget(parent), ui(new Ui::OrbitSamplingReport) {
  ui->setupUi(this);
  if (!m_SamplingReport || !m_SamplingReport->HasCallstacks()) {
    ui->NextCallstackButton->setEnabled(false);
    ui->NextCallstackButton->setStyleSheet(
        QString::fromUtf8("QPushButton:disabled{ color: gray }"));
    ui->PreviousCallstackButton->setEnabled(false);
    ui->PreviousCallstackButton->setStyleSheet(
        QString::fromUtf8("QPushButton:disabled{ color: gray }"));
  }

  QList<int> sizes;
  sizes.append(5000);
  sizes.append(5000);
  ui->splitter->setSizes(sizes);
}

//-----------------------------------------------------------------------------
OrbitSamplingReport::~OrbitSamplingReport() { delete ui; }

//-----------------------------------------------------------------------------
void OrbitSamplingReport::Initialize(DataView* callstack_data_view,
                                     std::shared_ptr<SamplingReport> report) {
  ui->CallstackTreeView->Initialize(
      callstack_data_view, SelectionType::kExtended, FontType::kDefault, false);
  m_SamplingReport = report;

  if (!report) return;

  m_SamplingReport->SetUiRefreshFunc([&]() { this->Refresh(); });

  for (SamplingReportDataView& report_data_view : report->GetThreadReports()) {
    QWidget* tab = new QWidget();
    tab->setObjectName(QStringLiteral("tab"));

    QGridLayout* gridLayout_2 = new QGridLayout(tab);
    gridLayout_2->setObjectName(QStringLiteral("gridLayout_2"));
    OrbitDataViewPanel* treeView = new OrbitDataViewPanel(tab);
    treeView->SetDataModel(&report_data_view);

    if (!report_data_view.IsSortingAllowed()) {
      treeView->GetTreeView()->setSortingEnabled(false);
    } else {
      int column = report_data_view.GetDefaultSortingColumn();
      Qt::SortOrder order =
          report_data_view.GetColumns()[column].initial_order ==
                  DataView::SortingOrder::Ascending
              ? Qt::AscendingOrder
              : Qt::DescendingOrder;
      treeView->GetTreeView()->sortByColumn(column, order);
    }

    treeView->setObjectName(QStringLiteral("treeView"));
    gridLayout_2->addWidget(treeView, 0, 0, 1, 1);
    treeView->GetTreeView()->setSelectionMode(OrbitTreeView::ExtendedSelection);
    treeView->GetTreeView()->header()->resizeSections(
        QHeaderView::ResizeToContents);

    treeView->Link(ui->CallstackTreeView);

    QString threadName = QString::fromStdString(report_data_view.GetName());
    ui->tabWidget->addTab(tab, threadName);
  }
}
{'fraction_non_alphanumeric': 0.22636103151862463, 'fraction_numerical': 0.008764537333558066, 'mean_word_length': 2.6925948973242066, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6935912', 'n_tokens_mistral': 1714, 'n_tokens_neox': 1667, 'n_words': 226}