Triage cleanup (#2324)
* regex for version * fields names improved * codestyle * m prefix for fsmodel * string duplication removed * find in files: show all entries * spaces * added hint to checkboxes; element naming fixed * layout naming improvement * spacing 6->1
This commit is contained in:
parent
acd2a92efc
commit
afe59531c7
|
@ -19,7 +19,10 @@ const int MAX_ERRORS = 100;
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow),
|
||||||
|
mVersionRe("^(your|head|1.[0-9][0-9]) .*"),
|
||||||
|
hFiles{"*.hpp", "*.h", "*.hxx", "*.hh", "*.tpp", "*.txx"},
|
||||||
|
srcFiles{"*.cpp", "*.cxx", "*.cc", "*.c++", "*.C", "*.c", "*.cl"}
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
std::srand(static_cast<unsigned int>(std::time(Q_NULLPTR)));
|
std::srand(static_cast<unsigned int>(std::time(Q_NULLPTR)));
|
||||||
|
@ -27,14 +30,18 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
if (!workFolder.exists()) {
|
if (!workFolder.exists()) {
|
||||||
workFolder.mkdir(WORK_FOLDER);
|
workFolder.mkdir(WORK_FOLDER);
|
||||||
}
|
}
|
||||||
fsmodel.setRootPath(WORK_FOLDER);
|
|
||||||
fsmodel.setReadOnly(true);
|
mFSmodel.setRootPath(WORK_FOLDER);
|
||||||
fsmodel.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
mFSmodel.setReadOnly(true);
|
||||||
ui->directoryTree->setModel(&fsmodel);
|
mFSmodel.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
||||||
|
ui->directoryTree->setModel(&mFSmodel);
|
||||||
QHeaderView * header = ui->directoryTree->header();
|
QHeaderView * header = ui->directoryTree->header();
|
||||||
for(int i = 1; i < header->length(); ++i)
|
for(int i = 1; i < header->length(); ++i) // hide all except [0]
|
||||||
header->hideSection(i);
|
header->hideSection(i);
|
||||||
ui->directoryTree->setRootIndex(fsmodel.index(WORK_FOLDER));
|
ui->directoryTree->setRootIndex(mFSmodel.index(WORK_FOLDER));
|
||||||
|
|
||||||
|
ui->hFilesFilter->setToolTip(hFiles.join(','));
|
||||||
|
ui->srcFilesFilter->setToolTip(srcFiles.join(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -78,8 +85,8 @@ void MainWindow::load(QTextStream &textStream)
|
||||||
mAllErrors << errorMessage;
|
mAllErrors << errorMessage;
|
||||||
errorMessage.clear();
|
errorMessage.clear();
|
||||||
} else if (!url.isEmpty() && QRegExp(".*: (error|warning|style|note):.*").exactMatch(line)) {
|
} else if (!url.isEmpty() && QRegExp(".*: (error|warning|style|note):.*").exactMatch(line)) {
|
||||||
if (QRegExp("^(head|1.[0-9][0-9]) .*").exactMatch(line)) {
|
if (mVersionRe.exactMatch(line)) {
|
||||||
const QString version = line.mid(0,4);
|
const QString version = line.mid(0, 4);
|
||||||
if (versions.indexOf(version) < 0)
|
if (versions.indexOf(version) < 0)
|
||||||
versions << version;
|
versions << version;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +143,7 @@ void MainWindow::filter(QString filter)
|
||||||
allErrors.removeAt(i);
|
allErrors.removeAt(i);
|
||||||
}
|
}
|
||||||
std::random_shuffle(allErrors.begin(), allErrors.end());
|
std::random_shuffle(allErrors.begin(), allErrors.end());
|
||||||
ui->results->addItems(allErrors.mid(0,MAX_ERRORS));
|
ui->results->addItems(allErrors.mid(0, MAX_ERRORS));
|
||||||
ui->results->sortItems();
|
ui->results->sortItems();
|
||||||
} else {
|
} else {
|
||||||
ui->results->addItems(allErrors);
|
ui->results->addItems(allErrors);
|
||||||
|
@ -170,7 +177,7 @@ bool MainWindow::runProcess(const QString &programName, const QStringList &argum
|
||||||
|
|
||||||
bool MainWindow::wget(const QString &url)
|
bool MainWindow::wget(const QString &url)
|
||||||
{
|
{
|
||||||
return runProcess("wget", QStringList() << url);
|
return runProcess("wget", QStringList{url});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::unpackArchive(const QString &archiveName)
|
bool MainWindow::unpackArchive(const QString &archiveName)
|
||||||
|
@ -208,25 +215,27 @@ void MainWindow::showResult(QListWidgetItem *item)
|
||||||
return;
|
return;
|
||||||
const QString url = lines[0];
|
const QString url = lines[0];
|
||||||
QString msg = lines[1];
|
QString msg = lines[1];
|
||||||
if (QRegExp("^(head|1.[0-9][0-9]) .*").exactMatch(msg))
|
if (mVersionRe.exactMatch(msg))
|
||||||
msg = msg.mid(5);
|
msg = msg.mid(5);
|
||||||
const QString archiveName = url.mid(url.lastIndexOf("/") + 1);
|
const QString archiveName = url.mid(url.lastIndexOf("/") + 1);
|
||||||
const int pos1 = msg.indexOf(":");
|
const int pos1 = msg.indexOf(":");
|
||||||
const int pos2 = msg.indexOf(":", pos1+1);
|
const int pos2 = msg.indexOf(":", pos1+1);
|
||||||
const QString fileName = WORK_FOLDER + '/' + msg.left(msg.indexOf(":"));
|
const QString fileName = WORK_FOLDER + '/' + msg.left(msg.indexOf(":"));
|
||||||
const int lineNumber = msg.midRef(pos1+1,pos2-pos1-1).toInt();
|
const int lineNumber = msg.midRef(pos1+1, pos2-pos1-1).toInt();
|
||||||
|
|
||||||
if (!QFileInfo::exists(fileName)) {
|
if (!QFileInfo::exists(fileName)) {
|
||||||
if (QFileInfo::exists(DACA2_PACKAGES + '/' + archiveName.mid(0,archiveName.indexOf(".tar.")) + ".tar.xz")) {
|
const QString daca2archiveFile {DACA2_PACKAGES + '/' + archiveName.mid(0,archiveName.indexOf(".tar.")) + ".tar.xz"};
|
||||||
if (!unpackArchive(DACA2_PACKAGES + '/' + archiveName.mid(0,archiveName.indexOf(".tar.")) + ".tar.xz"))
|
if (QFileInfo::exists(daca2archiveFile)) {
|
||||||
|
if (!unpackArchive(daca2archiveFile))
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (!QFileInfo::exists(WORK_FOLDER + '/' + archiveName)) {
|
const QString archiveFullPath {WORK_FOLDER + '/' + archiveName};
|
||||||
|
if (!QFileInfo::exists(archiveFullPath)) {
|
||||||
// Download archive
|
// Download archive
|
||||||
if (!wget(url))
|
if (!wget(url))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!unpackArchive(WORK_FOLDER + '/' + archiveName))
|
if (!unpackArchive(archiveFullPath))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,31 +255,31 @@ void MainWindow::showSrcFile(const QString &fileName, const QString &url, const
|
||||||
QTextStream textStream(&f);
|
QTextStream textStream(&f);
|
||||||
const QString fileData = textStream.readAll();
|
const QString fileData = textStream.readAll();
|
||||||
ui->code->setError(fileData, lineNumber, QStringList());
|
ui->code->setError(fileData, lineNumber, QStringList());
|
||||||
|
|
||||||
ui->edit1->setText(url);
|
|
||||||
ui->edit2->setText(fileName);
|
|
||||||
f.close();
|
f.close();
|
||||||
ui->directoryTree->setCurrentIndex(fsmodel.index(fileName));
|
|
||||||
|
ui->urlEdit->setText(url);
|
||||||
|
ui->fileEdit->setText(fileName);
|
||||||
|
ui->directoryTree->setCurrentIndex(mFSmodel.index(fileName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::fileTreeFilter(QString str) {
|
void MainWindow::fileTreeFilter(QString str)
|
||||||
fsmodel.setNameFilters(QStringList{"*" + str + "*"});
|
{
|
||||||
fsmodel.setNameFilterDisables(false);
|
mFSmodel.setNameFilters(QStringList{"*" + str + "*"});
|
||||||
|
mFSmodel.setNameFilterDisables(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::findInFilesClicked() {
|
void MainWindow::findInFilesClicked()
|
||||||
|
{
|
||||||
ui->tabWidget->setCurrentIndex(1);
|
ui->tabWidget->setCurrentIndex(1);
|
||||||
ui->inFilesResult->clear();
|
ui->inFilesResult->clear();
|
||||||
const QString text = ui->lineEdit->text();
|
const QString text = ui->filterEdit->text();
|
||||||
|
|
||||||
QStringList filter;
|
QStringList filter;
|
||||||
if(ui->hFilesFilter->isChecked()) {
|
if(ui->hFilesFilter->isChecked())
|
||||||
filter << "*.hpp" << "*.h" << "*.hxx" << "*.hh" << "*.tpp" << "*.txx";
|
filter.append(hFiles);
|
||||||
}
|
if(ui->srcFilesFilter->isChecked())
|
||||||
if(ui->srcFilter->isChecked()) {
|
filter.append(srcFiles);
|
||||||
filter << "*.cpp" << "*.cxx" << "*.cc" << "*.c++" << "*.C" << "*.c" << "*.cl";
|
|
||||||
}
|
|
||||||
|
|
||||||
QMimeDatabase mimeDatabase;
|
QMimeDatabase mimeDatabase;
|
||||||
QDirIterator it(WORK_FOLDER, filter, QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
QDirIterator it(WORK_FOLDER, filter, QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
||||||
|
@ -295,18 +304,19 @@ void MainWindow::findInFilesClicked() {
|
||||||
line = in.readLine();
|
line = in.readLine();
|
||||||
if (line.contains(text, Qt::CaseInsensitive)) {
|
if (line.contains(text, Qt::CaseInsensitive)) {
|
||||||
ui->inFilesResult->addItem(fileName.mid(common_path_len) + QString{":"} + QString::number(lineN));
|
ui->inFilesResult->addItem(fileName.mid(common_path_len) + QString{":"} + QString::number(lineN));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::directorytreeDoubleClick() {
|
void MainWindow::directorytreeDoubleClick()
|
||||||
showSrcFile(fsmodel.filePath(ui->directoryTree->currentIndex()), "", 1);
|
{
|
||||||
|
showSrcFile(mFSmodel.filePath(ui->directoryTree->currentIndex()), "", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::searchResultsDoubleClick() {
|
void MainWindow::searchResultsDoubleClick()
|
||||||
|
{
|
||||||
QString filename = ui->inFilesResult->currentItem()->text();
|
QString filename = ui->inFilesResult->currentItem()->text();
|
||||||
const auto idx = filename.lastIndexOf(':');
|
const auto idx = filename.lastIndexOf(':');
|
||||||
const int line = filename.midRef(idx + 1).toInt();
|
const int line = filename.midRef(idx + 1).toInt();
|
||||||
|
|
|
@ -41,7 +41,11 @@ private:
|
||||||
void showSrcFile(const QString &fileName, const QString &url, const int lineNumber);
|
void showSrcFile(const QString &fileName, const QString &url, const int lineNumber);
|
||||||
|
|
||||||
QStringList mAllErrors;
|
QStringList mAllErrors;
|
||||||
QFileSystemModel fsmodel;
|
QFileSystemModel mFSmodel;
|
||||||
|
const QRegExp mVersionRe;
|
||||||
|
|
||||||
|
const QStringList hFiles;
|
||||||
|
const QStringList srcFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -15,8 +15,14 @@
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="middleLayout">
|
<layout class="QVBoxLayout" name="middleLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="CodeEditor" name="code">
|
<widget class="CodeEditor" name="code">
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
|
@ -25,7 +31,10 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="urlFileLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="urllabel">
|
<widget class="QLabel" name="urllabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -34,7 +43,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="edit1"/>
|
<widget class="QLineEdit" name="urlEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="filelabel">
|
<widget class="QLabel" name="filelabel">
|
||||||
|
@ -44,7 +53,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="edit2"/>
|
<widget class="QLineEdit" name="fileEdit"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
@ -71,12 +80,21 @@
|
||||||
<attribute name="dockWidgetArea">
|
<attribute name="dockWidgetArea">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</attribute>
|
</attribute>
|
||||||
<widget class="QWidget" name="dockWidgetContents">
|
<widget class="QWidget" name="leftDockWidgetContents">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="leftDockVerticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="loadLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="loadFile">
|
<widget class="QPushButton" name="loadFile">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -117,7 +135,10 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="versionLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="versionLabel">
|
<widget class="QLabel" name="versionLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -165,14 +186,23 @@
|
||||||
<attribute name="dockWidgetArea">
|
<attribute name="dockWidgetArea">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</attribute>
|
</attribute>
|
||||||
<widget class="QWidget" name="dockWidgetContents_5">
|
<widget class="QWidget" name="rightDockWidgetContents">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="filesNavigatorLayout">
|
<layout class="QVBoxLayout" name="filesNavigatorLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="filterLayout">
|
<layout class="QHBoxLayout" name="filterLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEdit">
|
<widget class="QLineEdit" name="filterEdit">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>16777215</width>
|
<width>16777215</width>
|
||||||
|
@ -212,6 +242,9 @@
|
||||||
<string>Filesystem</string>
|
<string>Filesystem</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="directoryTree">
|
<widget class="QTreeView" name="directoryTree">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -241,6 +274,9 @@
|
||||||
<string>In Files Result</string>
|
<string>In Files Result</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="inFilesResult">
|
<widget class="QListWidget" name="inFilesResult">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -253,6 +289,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="fileFilterLayout">
|
<layout class="QHBoxLayout" name="fileFilterLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="hFilesFilter">
|
<widget class="QCheckBox" name="hFilesFilter">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -264,7 +303,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="srcFilter">
|
<widget class="QCheckBox" name="srcFilesFilter">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>*.c, *.cpp,...</string>
|
<string>*.c, *.cpp,...</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -296,7 +335,7 @@
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>lineEdit</sender>
|
<sender>filterEdit</sender>
|
||||||
<signal>textChanged(QString)</signal>
|
<signal>textChanged(QString)</signal>
|
||||||
<receiver>MainWindow</receiver>
|
<receiver>MainWindow</receiver>
|
||||||
<slot>fileTreeFilter(QString)</slot>
|
<slot>fileTreeFilter(QString)</slot>
|
||||||
|
|
Loading…
Reference in New Issue