forked from danmar/cppcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
116 lines (100 loc) · 3.17 KB
/
mainwindow.cpp
File metadata and controls
116 lines (100 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include "mainwindow.h"
#include "applicationsettings.h"
#include "configureprojects.h"
#include "graph.h"
#include "resultsform.h"
#include "settingsdialog.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QDir>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
projectList.load(QDir::homePath() + "/.cppcheck-gui-2.xml");
connect(ui->projectwidget, SIGNAL(scan()), this, SLOT(scan()));
connect(ui->projectwidget, SIGNAL(log()), this, SLOT(log()));
connect(ui->projectwidget, SIGNAL(diff()), this, SLOT(diff()));
connect(ui->projectwidget, SIGNAL(trend()), this, SLOT(trend()));
// TODO: right now we don't show anything on the status bar
this->statusBar()->hide();
ApplicationSettings settings;
if (settings.currentProject.isEmpty() && !projectList.projects.isEmpty()) {
settings.currentProject = projectList.projectNames().first();
settings.save();
}
ui->projectwidget->setProject(settings.currentProject);
ui->projects->addItems(projectList.projectNames());
ui->projects->setCurrentIndex(projectList.projectNames().indexOf(settings.currentProject));
QHBoxLayout *layout = new QHBoxLayout;
ui->workarea->setLayout(layout);
resultsForm = new ResultsForm(this);
resultsForm->hide();
layout->addWidget(resultsForm);
graph = new Graph(this);
graph->hide();
layout->addWidget(graph);
}
MainWindow::~MainWindow()
{
projectList.save(QDir::homePath() + "/.cppcheck-gui-2.xml");
delete ui;
}
void MainWindow::settings()
{
qDebug() << "MainWindow::settings";
SettingsDialog *dialog = new SettingsDialog(this);
dialog->show();
}
void MainWindow::configureProjects()
{
qDebug() << "MainWindow::configureProjects";
ConfigureProjects *dialog = new ConfigureProjects(this,projectList);
ApplicationSettings settings;
settings.currentProject = ui->projects->currentText();
if (dialog->exec() == QDialog::Accepted) {
projectList.swap(dialog->projectList);
ui->projects->clear();
const QStringList s = projectList.projectNames();
ui->projects->addItems(s);
ui->projects->setCurrentIndex(s.indexOf(settings.currentProject));
}
}
void MainWindow::selectProject(QString projectName)
{
ApplicationSettings settings;
settings.currentProject = projectName;
settings.save();
ui->projectwidget->setProject(projectName);
}
void MainWindow::scan()
{
const ProjectList::Project *project = projectList.getproject(ui->projectwidget->getProjectName());
if (project) {
graph->hide();
resultsForm->show();
resultsForm->scan(*project);
}
}
void MainWindow::log()
{
const ProjectList::Project *project = projectList.getproject(ui->projectwidget->getProjectName());
if (project) {
graph->hide();
resultsForm->show();
resultsForm->showResults(*project);
}
}
void MainWindow::diff()
{
graph->diff(ui->projectwidget->getProjectName());
resultsForm->hide();
graph->show();
}
void MainWindow::trend()
{
graph->trend(ui->projectwidget->getProjectName());
resultsForm->hide();
graph->show();
}