代码拉取完成,页面将自动刷新
#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) + " 行"));
// }
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。