Commit 9b38547b authored by frysch's avatar frysch

performance

parent 98102f0e
......@@ -63,8 +63,8 @@ void MainWindow::lines()
subs.append(subDirs(f));
folderList.append(subs);
}
auto count = countLines(folderList);
ui->label_number->setText(QString::number(count));
countLines(folderList);
}
QStringList subDirs(const QDir &dir)
......@@ -86,33 +86,32 @@ QStringList MainWindow::folders()
return content.isEmpty() ? QStringList() : content.split("\n");
}
int MainWindow::countLines(const QStringList &folders)
void MainWindow::countLines(const QStringList &folders)
{
QStringList filters = QStringList() << "*.cpp" << "*.h" << "*.cl";
auto filters = QStringList() << "*.cpp" << "*.h" << "*.cl";
QString analysis("$$$$$ ANALYSIS $$$$$\n\n"
"located folders:\n" + folders.join("\n") + "\n\n" +
"located files (" + filters.join(", ") + "):\n");
int lineCounter = 0;
QFile curFile;
auto lineCounter = 0;
foreach(QString folder, folders)
for(QDir curDir : folders)
{
QDir codeDir(folder);
QStringList fileList = codeDir.entryList(filters);
foreach(QString fileN, fileList)
auto fileList = curDir.entryList(filters);
for(const auto &fileN : fileList)
{
QFile file(codeDir.path()+"/" +fileN);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QString allLines = file.readAll();
auto theLines = allLines.split("\n");
curFile.setFileName(curDir.path()+"/" +fileN);
curFile.open(QIODevice::ReadOnly | QIODevice::Text);
auto allLines = QString(curFile.readAll());
auto listOFLines = allLines.split("\n");
if(!ui->checkBox_emptyLines->isChecked())
theLines.removeAll("");
auto curLength = theLines.length();
listOFLines.removeAll("");
auto curLength = listOFLines.length();
analysis.append(fileN + ": " + QString::number(curLength) + "\n");
lineCounter += curLength;
file.close();
curFile.close();
}
}
ui->textBrowser_analysis->setText(analysis);
return lineCounter;
ui->label_number->setText(QString::number(lineCounter));
}
......@@ -23,7 +23,7 @@ signals:
void updateFolderList();
private:
void lines();
int countLines(const QStringList &folders);
void countLines(const QStringList &folders);
QStringList folders();
Ui::MainWindow *ui;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment