1 Star 5 Fork 3

chen227/calcCodeLine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
widget.cpp 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
chen227 提交于 2018-03-27 10:46 . first commit
#include "widget.h"
#include "ui_widget.h"
#include "CalcCode.h"
#include <QDir>
#include <QFileDialog>
#include <QDebug>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
this->resize(800,600);
this->setWindowTitle("计算代码行数");
m_sizeNum = 0;
m_fileNum = 0;
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_pushButton_clicked()
{
//open
QString path = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
QDir::currentPath(),
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
m_calcQThread = new CalcCode(this);
connect(m_calcQThread,SIGNAL(getValue(QVariantList)),this,SLOT(onGetValue(QVariantList)));
connect(m_calcQThread,SIGNAL(getOneValue(QVariantMap)),this,SLOT(onGetOneValue(QVariantMap)));
connect(m_calcQThread,SIGNAL(finished()),m_calcQThread,SLOT(deleteLater()));
m_calcQThread->setPath(path);
m_calcQThread->start();
ui->listWidget->clear();
m_sizeNum = 0;
m_fileNum = 0;
}
void Widget::onGetValue(const QVariantList &data)
{
ui->listWidget->addItem("总文件数:" + QString::number(m_fileNum) + " 总行数:"+QString::number(m_sizeNum) + " 行");
}
//一项项获取item
void Widget::onGetOneValue(const QVariantMap &data)
{
// if(data.value("type") == "h" || data.value("type") == "cpp" || data.value("type") == "qml"){
QString filePath = data.value("filePath").toString();
int lineNum = data.value("lineNum").toInt();
m_sizeNum += lineNum;
m_fileNum++;
ui->listWidget->addItem((filePath + ": " + QString::number(lineNum) + " 行"));
// }
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chen227/calcCodeLine.git
git@gitee.com:chen227/calcCodeLine.git
chen227
calcCodeLine
calcCodeLine
master

搜索帮助