Skip to content

Commit d44477c

Browse files
committed
Adding file selection dialog for project generation.
1 parent 86a8b2a commit d44477c

6 files changed

+209
-12
lines changed

doxygen.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
**/
2121

2222
#include "doxygen.h"
23+
#include "doxygenfilesdialog.h"
2324

2425
#include <QObject>
2526
#include <plugins/cppeditor/cppeditorconstants.h>
@@ -552,7 +553,20 @@ uint Doxygen::documentProject(ProjectExplorer::Project *p, const DoxygenSettings
552553

553554
uint count = 0;
554555
Core::EditorManager *editorManager = Core::EditorManager::instance();
555-
QStringList files = p->files(ProjectExplorer::Project::ExcludeGeneratedFiles);
556+
QStringList allFiles = p->files(ProjectExplorer::Project::ExcludeGeneratedFiles);
557+
QStringList files;
558+
559+
allFiles = allFiles.filter(QRegExp("\\.(h|hpp|c|cpp)$"));
560+
DoxygenFilesDialog *dialog = new DoxygenFilesDialog(allFiles, NULL);
561+
562+
if (dialog->result() != QDialog::Accepted)
563+
{
564+
delete dialog;
565+
return 0;
566+
}
567+
dialog->getFilesList(&files);
568+
delete dialog;
569+
556570
QProgressDialog progress("Processing files...", "Cancel", 0, files.size());
557571
progress.setWindowModality(Qt::WindowModal);
558572

doxygen.pro

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ SOURCES += doxygenplugin.cpp \
66
doxygensettings.cpp \
77
doxygensettingsstruct.cpp \
88
doxygensettingswidget.cpp \
9-
doxygen.cpp
9+
doxygen.cpp \
10+
doxygenfilesdialog.cpp
1011

1112
HEADERS += doxygenplugin.h \
1213
doxygen_global.h \
1314
doxygenconstants.h \
1415
doxygensettings.h \
1516
doxygensettingsstruct.h \
1617
doxygensettingswidget.h \
17-
doxygen.h
18+
doxygen.h \
19+
doxygenfilesdialog.h
1820

1921
FORMS += \
20-
doxygensettingswidget.ui
22+
doxygensettingswidget.ui \
23+
doxygenfilesdialog.ui
2124

2225
RESOURCES += doxygen.qrc
2326

doxygenfilesdialog.cpp

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include "doxygenfilesdialog.h"
2+
#include "ui_doxygenfilesdialog.h"
3+
4+
#include <QListWidget>
5+
#include <QListWidgetItem>
6+
7+
DoxygenFilesDialog::DoxygenFilesDialog(const QStringList &in, QWidget *parent) :
8+
QDialog(parent),
9+
ui(new Ui::DoxygenFilesDialog)
10+
{
11+
ui->setupUi(this);
12+
13+
QStringListIterator it(in);
14+
15+
while (it.hasNext())
16+
{
17+
QListWidgetItem *listItem = new QListWidgetItem(it.next());
18+
listItem->setCheckState(Qt::Checked);
19+
ui->listWidget->addItem(listItem);
20+
}
21+
22+
connect(ui->b_all, SIGNAL(clicked(bool)), this, SLOT(checkAll()));
23+
connect(ui->b_none, SIGNAL(clicked(bool)), this, SLOT(checkNone()));
24+
connect(ui->b_cancel, SIGNAL(clicked(bool)), this, SLOT(reject()));
25+
connect(ui->b_ok, SIGNAL(clicked(bool)), this, SLOT(accept()));
26+
27+
this->exec();
28+
}
29+
30+
DoxygenFilesDialog::~DoxygenFilesDialog()
31+
{
32+
delete ui;
33+
}
34+
35+
uint DoxygenFilesDialog::getFilesList(QStringList *out)
36+
{
37+
uint count = 0;
38+
for (int i=0; i< ui->listWidget->count(); i++)
39+
{
40+
if (ui->listWidget->item(i)->checkState() == Qt::Checked)
41+
{
42+
out->append(ui->listWidget->item(i)->text());
43+
count++;
44+
}
45+
}
46+
return count;
47+
}
48+
49+
void DoxygenFilesDialog::checkAll()
50+
{
51+
for (int i=0; i< ui->listWidget->count(); i++)
52+
{
53+
if (ui->listWidget->item(i)->checkState() == Qt::Unchecked)
54+
ui->listWidget->item(i)->setCheckState(Qt::Checked);
55+
}
56+
}
57+
58+
void DoxygenFilesDialog::checkNone()
59+
{
60+
for (int i=0; i< ui->listWidget->count(); i++)
61+
{
62+
if (ui->listWidget->item(i)->checkState() == Qt::Checked)
63+
ui->listWidget->item(i)->setCheckState(Qt::Unchecked);
64+
}
65+
}

doxygenfilesdialog.h

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef DOXYGENFILESDIALOG_H
2+
#define DOXYGENFILESDIALOG_H
3+
4+
#include <QDialog>
5+
6+
namespace Ui {
7+
class DoxygenFilesDialog;
8+
}
9+
10+
class DoxygenFilesDialog : public QDialog
11+
{
12+
Q_OBJECT
13+
14+
public:
15+
explicit DoxygenFilesDialog(const QStringList &in, QWidget *parent = 0);
16+
~DoxygenFilesDialog();
17+
uint getFilesList(QStringList *out);
18+
19+
private:
20+
Ui::DoxygenFilesDialog *ui;
21+
22+
private slots:
23+
void checkAll();
24+
void checkNone();
25+
};
26+
27+
#endif // DOXYGENFILESDIALOG_H

doxygenfilesdialog.ui

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>DoxygenFilesDialog</class>
4+
<widget class="QDialog" name="DoxygenFilesDialog">
5+
<property name="windowModality">
6+
<enum>Qt::ApplicationModal</enum>
7+
</property>
8+
<property name="geometry">
9+
<rect>
10+
<x>0</x>
11+
<y>0</y>
12+
<width>400</width>
13+
<height>300</height>
14+
</rect>
15+
</property>
16+
<property name="windowTitle">
17+
<string>Select files to document</string>
18+
</property>
19+
<property name="modal">
20+
<bool>true</bool>
21+
</property>
22+
<layout class="QVBoxLayout" name="verticalLayout">
23+
<item>
24+
<widget class="QListWidget" name="listWidget">
25+
<property name="sortingEnabled">
26+
<bool>true</bool>
27+
</property>
28+
</widget>
29+
</item>
30+
<item>
31+
<widget class="QFrame" name="frame">
32+
<property name="minimumSize">
33+
<size>
34+
<width>0</width>
35+
<height>50</height>
36+
</size>
37+
</property>
38+
<property name="frameShape">
39+
<enum>QFrame::StyledPanel</enum>
40+
</property>
41+
<property name="frameShadow">
42+
<enum>QFrame::Raised</enum>
43+
</property>
44+
<layout class="QHBoxLayout" name="horizontalLayout">
45+
<item>
46+
<widget class="QPushButton" name="b_all">
47+
<property name="text">
48+
<string>Select All</string>
49+
</property>
50+
</widget>
51+
</item>
52+
<item>
53+
<widget class="QPushButton" name="b_none">
54+
<property name="text">
55+
<string>Select None</string>
56+
</property>
57+
</widget>
58+
</item>
59+
<item>
60+
<spacer name="horizontalSpacer">
61+
<property name="orientation">
62+
<enum>Qt::Horizontal</enum>
63+
</property>
64+
<property name="sizeHint" stdset="0">
65+
<size>
66+
<width>40</width>
67+
<height>20</height>
68+
</size>
69+
</property>
70+
</spacer>
71+
</item>
72+
<item>
73+
<widget class="QPushButton" name="b_ok">
74+
<property name="text">
75+
<string>Ok</string>
76+
</property>
77+
</widget>
78+
</item>
79+
<item>
80+
<widget class="QPushButton" name="b_cancel">
81+
<property name="text">
82+
<string>Cancel</string>
83+
</property>
84+
</widget>
85+
</item>
86+
</layout>
87+
</widget>
88+
</item>
89+
</layout>
90+
</widget>
91+
<resources/>
92+
<connections/>
93+
</ui>

doxygenplugin.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,9 @@ void DoxygenPlugin::documentSpecificProject()
222222

223223
void DoxygenPlugin::documentCurrentProject()
224224
{
225-
if (QMessageBox::question((QWidget*)this->parent(),
226-
"Doxygen", "Document current project?",
227-
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
228-
{
229-
uint count = Doxygen::instance()->documentCurrentProject(settings());
230-
QString msg;
231-
this->externalString(msg.sprintf("Doxygen blocs generated: %u", count));
232-
}
225+
uint count = Doxygen::instance()->documentCurrentProject(settings());
226+
QString msg;
227+
this->externalString(msg.sprintf("Doxygen blocs generated: %u", count));
233228
}
234229

235230
bool DoxygenPlugin::buildDocumentation() // TODO: refactor

0 commit comments

Comments
 (0)