Commit 25d716c2 authored by frysch's avatar frysch

custom file extensions

add also some more default c++ file extensions
parent 9b38547b
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QInputDialog>
static auto FILTERS = QStringList() << "*.cpp" << "*.cc" << "*.cxx" << "*.c++" << "*.c" << "*.tpp"
<< "*.hpp" << "*.hh" << "*.hxx" << "*.h++" << "*.h" << "*.cl";
static QStringList subDirs(const QDir &dir);
......@@ -48,6 +52,33 @@ void MainWindow::on_pushButton_removeFirst_clicked()
}
}
void MainWindow::on_pushButton_addExtension_clicked()
{
bool ok;
auto text = QInputDialog::getText(this, "Insert file extension",
"*.", QLineEdit::Normal, "txt", &ok);
if(ok) {
FILTERS << "*."+text;
emit updateFolderList();
}
}
void MainWindow::on_pushButton_removeFirstExtension_clicked()
{
if(!FILTERS.isEmpty()) {
FILTERS.removeFirst();
emit updateFolderList();
}
}
void MainWindow::on_pushButton_removeLastExtension_clicked()
{
if(!FILTERS.isEmpty()) {
FILTERS.removeLast();
emit updateFolderList();
}
}
void MainWindow::lines()
{
auto folderList = folders();
......@@ -88,28 +119,29 @@ QStringList MainWindow::folders()
void MainWindow::countLines(const QStringList &folders)
{
auto filters = QStringList() << "*.cpp" << "*.h" << "*.cl";
QString analysis("$$$$$ ANALYSIS $$$$$\n\n"
"located folders:\n" + folders.join("\n") + "\n\n" +
"located files (" + filters.join(", ") + "):\n");
"located files with extensions\n" + FILTERS.join(", ") + ":\n\n");
QFile curFile;
auto lineCounter = 0;
for(QDir curDir : folders)
{
auto fileList = curDir.entryList(filters);
for(const auto &fileN : fileList)
if(!FILTERS.isEmpty()) {
for(QDir curDir : folders)
{
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())
listOFLines.removeAll("");
auto curLength = listOFLines.length();
analysis.append(fileN + ": " + QString::number(curLength) + "\n");
lineCounter += curLength;
curFile.close();
auto fileList = curDir.entryList(FILTERS);
for(const auto &fileN : fileList)
{
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())
listOFLines.removeAll("");
auto curLength = listOFLines.length();
analysis.append(fileN + ": " + QString::number(curLength) + "\n");
lineCounter += curLength;
curFile.close();
}
}
}
ui->textBrowser_analysis->setText(analysis);
......
......@@ -19,6 +19,11 @@ private slots:
void on_pushButton_addFolder_clicked();
void on_pushButton_removeLast_clicked();
void on_pushButton_removeFirst_clicked();
void on_pushButton_addExtension_clicked();
void on_pushButton_removeFirstExtension_clicked();
void on_pushButton_removeLastExtension_clicked();
signals:
void updateFolderList();
private:
......
......@@ -61,6 +61,27 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_addExtension">
<property name="text">
<string>add file extension</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_removeFirstExtension">
<property name="text">
<string>remove first extension</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_removeLastExtension">
<property name="text">
<string>remove last extension</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
......
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