<commit_before>#include "MainForm.h"
#include <algorithm>

MainForm::MainForm(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
    ui.setupUi(this);
    Center();
    DoEvents();
    ui.fileSystemTree->setColumnWidth(0, 240);
    ui.fileSystemTree->setColumnWidth(1, 150);

    cache = new QSettings("threexortwo", "Up");

    // Set the context menus
    SetContextMenus();

    iDisk.addFile(QString::fromUtf8(":/File System Icons/iDisk"), QSize(), QIcon::Normal, QIcon::Off);
    iFile.addFile(QString::fromUtf8(":/File System Icons/iFile"), QSize(), QIcon::Normal, QIcon::Off);
    iUsb.addFile(QString::fromUtf8(":/File System Icons/iUsb"), QSize(), QIcon::Normal, QIcon::Off);
    iFolder.addFile(QString::fromUtf8(":/File System Icons/iFolder"), QSize(), QIcon::Normal, QIcon::Off);
    iPartition.addFile(QString::fromUtf8(":/File System Icons/iPartition"), QSize(), QIcon::Normal, QIcon::Off);
}

MainForm::~MainForm()
{
    // Destroy the current drives, cleanup
    while(ActiveDrives.size())
    {
        if (!ActiveDrives.size())
            break;
        ActiveDrives[0]->Close();
        delete ActiveDrives[0];
        ActiveDrives.erase(ActiveDrives.begin());
    }
    // Clear the treeview
    while (ui.fileSystemTree->topLevelItemCount())
    {
        delete ui.fileSystemTree->topLevelItem(0);
    }
    delete cache;
}

string MainForm::GetCurrentItemPath(QTreeWidgetItem *Item)
{
    vector<std::string> ItemNames;
    QTreeWidgetItem *temp = Item;
    while (temp != 0)
    {
        ItemNames.push_back(Helpers::QStringToStdString(temp->text(0)));
        temp = temp->parent();
    }
    string built;
    for (int i = ItemNames.size() - 1; i >= 0; i--)
    {
        built += ItemNames.at(i);
        if (i != 0)
            built += "/";
    }
    return built;
}

void MainForm::OnCopyToLocalDiskClick( void )
{
    QString s;
    int size = ui.fileSystemTree->selectedItems().size();
    if (size == 0)
        return;
    else if (size == 1 && ui.fileSystemTree->selectedItems().at(0)->text(2) != QString::fromAscii("Folder"))
    {
        s = QFileDialog::getSaveFileName(this, QString::fromAscii("Select Where to Save File"), ui.fileSystemTree->selectedItems().at(0)->text(0));
    }
    else
    {
        QFileDialog qfd;
        qfd.setFileMode(QFileDialog::Directory);
        qfd.setOption(QFileDialog::ShowDirsOnly);
        s = qfd.getExistingDirectory(this, QString::fromAscii("Select Directory to Save Files"));
    }
    if (s.isEmpty() || s.isNull())
    {
        return;
    }

    // Get the paths of all selected items
    vector<std::string> Paths;
    for (int i = 0; i < ui.fileSystemTree->selectedItems().size(); i++)
        Paths.push_back(GetCurrentItemPath(ui.fileSystemTree->selectedItems().at(i)));

    ProgressDialog *pd = new ProgressDialog(this, OperationCopyToDisk, Paths, Helpers::QStringToStdString(s), ActiveDrives);

    pd->setModal(true);
    pd->show();
}

void MainForm::SetContextMenus( void )
{
    ui.fileSystemTree->addAction(ui.actionCopy_File_to_Local_Disk);
    QAction *sep = new QAction(this);
    sep->setSeparator(true);
    ui.fileSystemTree->addAction(sep);
    ui.fileSystemTree->addAction(ui.actionRename);

    connect(ui.actionCopy_File_to_Local_Disk, SIGNAL(triggered()), this, SLOT(OnCopyToLocalDiskClick()));
}

void MainForm::Center( void )
{
    QRect frect = frameGeometry();
    frect.moveCenter(QDesktopWidget().availableGeometry().center());
    move(frect.topLeft());
}

void MainForm::DoEvents( void )
{
    connect(ui.actionLoad_Devices, SIGNAL(triggered()), this, SLOT(OnLoadDevicesClick()));
    connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(ShowAbout()));
    connect(ui.fileSystemTree, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(OnTreeItemExpand(QTreeWidgetItem*)));
    connect(ui.fileSystemTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(OnTreeItemDoubleClick(QTreeWidgetItem*, int)));
}

Drive *MainForm::GetCurrentItemDrive(QTreeWidgetItem* Item)
{
    QString text = Item->text(0);
    qDebug(Helpers::QStringToStdString(text).c_str());
    QTreeWidgetItem *Parent = Item;
    while (Parent->parent() != 0)
        Parent = Parent->parent();

    for (int i = 0; i < (int)ActiveDrives.size(); i++)
    {
        Drive* d = ActiveDrives.at(i);
<commit_msg>MainForm: Removed some qDebug stuff<commit_after>#include "MainForm.h"
#include <algorithm>

MainForm::MainForm(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
    ui.setupUi(this);
    Center();
    DoEvents();
    ui.fileSystemTree->setColumnWidth(0, 240);
    ui.fileSystemTree->setColumnWidth(1, 150);

    cache = new QSettings("threexortwo", "Up");

    // Set the context menus
    SetContextMenus();

    iDisk.addFile(QString::fromUtf8(":/File System Icons/iDisk"), QSize(), QIcon::Normal, QIcon::Off);
    iFile.addFile(QString::fromUtf8(":/File System Icons/iFile"), QSize(), QIcon::Normal, QIcon::Off);
    iUsb.addFile(QString::fromUtf8(":/File System Icons/iUsb"), QSize(), QIcon::Normal, QIcon::Off);
    iFolder.addFile(QString::fromUtf8(":/File System Icons/iFolder"), QSize(), QIcon::Normal, QIcon::Off);
    iPartition.addFile(QString::fromUtf8(":/File System Icons/iPartition"), QSize(), QIcon::Normal, QIcon::Off);
}

MainForm::~MainForm()
{
    // Destroy the current drives, cleanup
    while(ActiveDrives.size())
    {
        if (!ActiveDrives.size())
            break;
        ActiveDrives[0]->Close();
        delete ActiveDrives[0];
        ActiveDrives.erase(ActiveDrives.begin());
    }
    // Clear the treeview
    while (ui.fileSystemTree->topLevelItemCount())
    {
        delete ui.fileSystemTree->topLevelItem(0);
    }
    delete cache;
}

string MainForm::GetCurrentItemPath(QTreeWidgetItem *Item)
{
    vector<std::string> ItemNames;
    QTreeWidgetItem *temp = Item;
    while (temp != 0)
    {
        ItemNames.push_back(Helpers::QStringToStdString(temp->text(0)));
        temp = temp->parent();
    }
    string built;
    for (int i = ItemNames.size() - 1; i >= 0; i--)
    {
        built += ItemNames.at(i);
        if (i != 0)
            built += "/";
    }
    return built;
}

void MainForm::OnCopyToLocalDiskClick( void )
{
    QString s;
    int size = ui.fileSystemTree->selectedItems().size();
    if (size == 0)
        return;
    else if (size == 1 && ui.fileSystemTree->selectedItems().at(0)->text(2) != QString::fromAscii("Folder"))
    {
        s = QFileDialog::getSaveFileName(this, QString::fromLocal8Bit("Select Where to Save File"), ui.fileSystemTree->selectedItems().at(0)->text(0));
    }
    else
    {
        QFileDialog qfd;
        qfd.setFileMode(QFileDialog::Directory);
        qfd.setOption(QFileDialog::ShowDirsOnly);
        s = qfd.getExistingDirectory(this, QString::fromAscii("Select Directory to Save Files"));
    }
    if (s.isEmpty() || s.isNull())
    {
        return;
    }

    // Get the paths of all selected items
    vector<std::string> Paths;
    for (int i = 0; i < ui.fileSystemTree->selectedItems().size(); i++)
    {
        Paths.push_back(GetCurrentItemPath(ui.fileSystemTree->selectedItems().at(i)));
    }
    ProgressDialog *pd = new ProgressDialog(this, OperationCopyToDisk, Paths, Helpers::QStringToStdString(s), ActiveDrives);

    pd->setModal(true);
    pd->show();
}

void MainForm::SetContextMenus( void )
{
    ui.fileSystemTree->addAction(ui.actionCopy_File_to_Local_Disk);
    QAction *sep = new QAction(this);
    sep->setSeparator(true);
    ui.fileSystemTree->addAction(sep);
    ui.fileSystemTree->addAction(ui.actionRename);

    connect(ui.actionCopy_File_to_Local_Disk, SIGNAL(triggered()), this, SLOT(OnCopyToLocalDiskClick()));
}

void MainForm::Center( void )
{
    QRect frect = frameGeometry();
    frect.moveCenter(QDesktopWidget().availableGeometry().center());
    move(frect.topLeft());
}

void MainForm::DoEvents( void )
{
    connect(ui.actionLoad_Devices, SIGNAL(triggered()), this, SLOT(OnLoadDevicesClick()));
    connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(ShowAbout()));
    connect(ui.fileSystemTree, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(OnTreeItemExpand(QTreeWidgetItem*)));
    connect(ui.fileSystemTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(OnTreeItemDoubleClick(QTreeWidgetItem*, int)));
}

Drive *MainForm::GetCurrentItemDrive(QTreeWidgetItem* Item)
{
    QTreeWidgetItem *Parent = Item;
    while (Parent->parent() != 0)
        Parent = Parent->parent();

    for (int i = 0; i < (int)ActiveDrives.size(); i++)
    {
        Drive* d = ActiveDrives.at(i);

{'fraction_non_alphanumeric': 0.15895348837209303, 'fraction_numerical': 0.007209302325581395, 'mean_word_length': 3.8565782044042916, 'pattern_counts': {'":': 10, '<': 13, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1302728', 'n_tokens_mistral': 2924, 'n_tokens_neox': 2845, 'n_words': 496}