<commit_before>/**************************************************************************
** This file is part of LiteIDE
**
** Copyright (c) 2011-2016 LiteIDE Team. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** Lesser General Public License for more details.
**
** In addition, as a special exception,  that plugins developed for LiteIDE,
** are allowed to remain closed sourced and can be distributed under any license .
** These rights are included in the file LGPL_EXCEPTION.txt in this package.
**
**************************************************************************/
// Module: newfiledialog.cpp
// Creator: visualfc <<EMAIL>>

#include "newfiledialog.h"
#include "ui_newfiledialog.h"

#include <QStandardItemModel>
#include <QStandardItem>
#include <QStringListModel>
#include <QDir>
#include <QFileInfo>
#include <QSettings>
#include <QTextCodec>
#include <QFileDialog>
#include <QMessageBox>
#include <QDateTime>
#include <QDebug>
//lite_memory_check_begin
#if defined(WIN32) && defined(_MSC_VER) &&  defined(_DEBUG)
     #define _CRTDBG_MAP_ALLOC
     #include <stdlib.h>
     #include <crtdbg.h>
     #define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
     #define new DEBUG_NEW
#endif
//lite_memory_check_end


NewFileDialog::NewFileDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::NewFileDialog)
{
    ui->setupUi(this);
    m_templateModel = new QStandardItemModel(this);
    m_pathModel = new QStringListModel(this);

    ui->templateTreeView->setModel(m_templateModel);
    ui->pathTreeView->setModel(m_pathModel);

    ui->pathTreeView->setEditTriggers(0);
    ui->pathTreeView->setRootIsDecorated(false);
    ui->pathTreeView->setHeaderHidden(true);

    ui->templateTreeView->setEditTriggers(0);
    ui->templateTreeView->setRootIsDecorated(false);
    ui->templateTreeView->setHeaderHidden(true);

    connect(ui->templateTreeView,SIGNAL(clicked(QModelIndex)),this,SLOT(activeTemplate(QModelIndex)));
    connect(ui->nameLineEdit,SIGNAL(textChanged(QString)),this,SLOT(nameLineChanged(QString)));
    connect(ui->locationLineEdit,SIGNAL(textChanged(QString)),this,SLOT(locationLineChanged(QString)));
    connect(ui->pathTreeView,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(activePath(QModelIndex)));
}

NewFileDialog::~NewFileDialog()
{
    delete ui;
}

void NewFileDialog::setPathList(const QStringList &pathList)
{
    m_pathModel->setStringList(pathList);
    if (m_gopath.isEmpty() && !pathList.isEmpty()) {
        m_gopath = pathList.first();
    }  
}

void NewFileDialog::setGopath(const QString &path)
{
    m_gopath = path;
}

void NewFileDialog::setProjectLocation(const QString &path)
{
    m_projectLocation = path;
}

void NewFileDialog::setFileLocation(const QString &path)
{
    m_fileLocation = path;
}

void NewFileDialog::updateLocation()
{
    ui->nameLineEdit->clear();
    QModelIndex index = ui->templateTreeView->currentIndex();
    if (index.isValid()) {
        activeTemplate(index);
    }
}

void NewFileDialog::accept()
{
    if (!m_cur.isValid()) {
        return;
    }

    QString location = ui->locationLineEdit->text();
    QString name = ui->nameLineEdit->text();

    if (name.isEmpty()) {
        return;
    }
    QDir dir(location);
    if (!dir.exists()) {
        if (!dir.mkpath(location)) {
            QMessageBox::warning(this,tr("Error"),tr("Could not create the target directory: %1").arg(location));
            return;
        }
    } else {
        if (m_cur.type != "file" && !dir.entryList(QDir::Files).isEmpty()) {
            int ret = QMessageBox::warning(this,tr("Warning"),QString(tr("Location %1 is not empty.\nUse the target directory anyway?")).arg(location),
                                 QMessageBox::Yes|QMessageBox::No,QMessageBox::No);
            if (ret != QMessageBox::Yes) {
                return;
            }
        }
    }
<commit_msg>check newfiledialog space name<commit_after>/**************************************************************************
** This file is part of LiteIDE
**
** Copyright (c) 2011-2016 LiteIDE Team. All rights reserved.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** Lesser General Public License for more details.
**
** In addition, as a special exception,  that plugins developed for LiteIDE,
** are allowed to remain closed sourced and can be distributed under any license .
** These rights are included in the file LGPL_EXCEPTION.txt in this package.
**
**************************************************************************/
// Module: newfiledialog.cpp
// Creator: visualfc <<EMAIL>>

#include "newfiledialog.h"
#include "ui_newfiledialog.h"

#include <QStandardItemModel>
#include <QStandardItem>
#include <QStringListModel>
#include <QDir>
#include <QFileInfo>
#include <QSettings>
#include <QTextCodec>
#include <QFileDialog>
#include <QMessageBox>
#include <QDateTime>
#include <QDebug>
//lite_memory_check_begin
#if defined(WIN32) && defined(_MSC_VER) &&  defined(_DEBUG)
     #define _CRTDBG_MAP_ALLOC
     #include <stdlib.h>
     #include <crtdbg.h>
     #define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
     #define new DEBUG_NEW
#endif
//lite_memory_check_end


NewFileDialog::NewFileDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::NewFileDialog)
{
    ui->setupUi(this);
    m_templateModel = new QStandardItemModel(this);
    m_pathModel = new QStringListModel(this);

    ui->templateTreeView->setModel(m_templateModel);
    ui->pathTreeView->setModel(m_pathModel);

    ui->pathTreeView->setEditTriggers(0);
    ui->pathTreeView->setRootIsDecorated(false);
    ui->pathTreeView->setHeaderHidden(true);

    ui->templateTreeView->setEditTriggers(0);
    ui->templateTreeView->setRootIsDecorated(false);
    ui->templateTreeView->setHeaderHidden(true);

    connect(ui->templateTreeView,SIGNAL(clicked(QModelIndex)),this,SLOT(activeTemplate(QModelIndex)));
    connect(ui->nameLineEdit,SIGNAL(textChanged(QString)),this,SLOT(nameLineChanged(QString)));
    connect(ui->locationLineEdit,SIGNAL(textChanged(QString)),this,SLOT(locationLineChanged(QString)));
    connect(ui->pathTreeView,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(activePath(QModelIndex)));
}

NewFileDialog::~NewFileDialog()
{
    delete ui;
}

void NewFileDialog::setPathList(const QStringList &pathList)
{
    m_pathModel->setStringList(pathList);
    if (m_gopath.isEmpty() && !pathList.isEmpty()) {
        m_gopath = pathList.first();
    }  
}

void NewFileDialog::setGopath(const QString &path)
{
    m_gopath = path;
}

void NewFileDialog::setProjectLocation(const QString &path)
{
    m_projectLocation = path;
}

void NewFileDialog::setFileLocation(const QString &path)
{
    m_fileLocation = path;
}

void NewFileDialog::updateLocation()
{
    ui->nameLineEdit->clear();
    QModelIndex index = ui->templateTreeView->currentIndex();
    if (index.isValid()) {
        activeTemplate(index);
    }
}

void NewFileDialog::accept()
{
    if (!m_cur.isValid()) {
        return;
    }

    QString location = ui->locationLineEdit->text().trimmed();
    QString name = ui->nameLineEdit->text().trimmed();

    if (name.isEmpty() || location.isEmpty()) {
        return;
    }
    QDir dir(location);
    if (!dir.exists()) {
        if (!dir.mkpath(location)) {
            QMessageBox::warning(this,tr("Error"),tr("Could not create the target directory: %1").arg(location));
            return;
        }
    } else {
        if (m_cur.type != "file" && !dir.entryList(QDir::Files).isEmpty()) {
            int ret = QMessageBox::warning(this,tr("Warning"),QString(tr("Location %1 is not empty.\nUse the target directory anyway?")).arg(location),
                                 QMessageBox::Yes|QMessageBox::No,QMessageBox::No);
            if (ret != QMessageBox::Yes) {
                return;
            }
        }
    }

{'fraction_non_alphanumeric': 0.15835540711735574, 'fraction_numerical': 0.0036853622020039155, 'mean_word_length': 4.3113149847094805, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7043880', 'n_tokens_mistral': 2634, 'n_tokens_neox': 2580, 'n_words': 598}