Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
LineCounter
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
frysch
LineCounter
Commits
25d716c2
Commit
25d716c2
authored
Feb 21, 2018
by
frysch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
custom file extensions
add also some more default c++ file extensions
parent
9b38547b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
16 deletions
+74
-16
mainwindow.cpp
mainwindow.cpp
+48
-16
mainwindow.h
mainwindow.h
+5
-0
mainwindow.ui
mainwindow.ui
+21
-0
No files found.
mainwindow.cpp
View file @
25d716c2
#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
);
...
...
mainwindow.h
View file @
25d716c2
...
...
@@ -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:
...
...
mainwindow.ui
View file @
25d716c2
...
...
@@ -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"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment