From d44477c81e8994051a9790e18fac02d54916e959 Mon Sep 17 00:00:00 2001 From: Fabien Poussin Date: Thu, 10 Dec 2015 17:59:07 +0100 Subject: [PATCH] Adding file selection dialog for project generation. --- doxygen.cpp | 16 +++++++- doxygen.pro | 9 ++-- doxygenfilesdialog.cpp | 65 +++++++++++++++++++++++++++++ doxygenfilesdialog.h | 27 ++++++++++++ doxygenfilesdialog.ui | 93 ++++++++++++++++++++++++++++++++++++++++++ doxygenplugin.cpp | 11 ++--- 6 files changed, 209 insertions(+), 12 deletions(-) create mode 100644 doxygenfilesdialog.cpp create mode 100644 doxygenfilesdialog.h create mode 100644 doxygenfilesdialog.ui diff --git a/doxygen.cpp b/doxygen.cpp index 316619e..335f5cf 100644 --- a/doxygen.cpp +++ b/doxygen.cpp @@ -20,6 +20,7 @@ **/ #include "doxygen.h" +#include "doxygenfilesdialog.h" #include #include @@ -552,7 +553,20 @@ uint Doxygen::documentProject(ProjectExplorer::Project *p, const DoxygenSettings uint count = 0; Core::EditorManager *editorManager = Core::EditorManager::instance(); - QStringList files = p->files(ProjectExplorer::Project::ExcludeGeneratedFiles); + QStringList allFiles = p->files(ProjectExplorer::Project::ExcludeGeneratedFiles); + QStringList files; + + allFiles = allFiles.filter(QRegExp("\\.(h|hpp|c|cpp)$")); + DoxygenFilesDialog *dialog = new DoxygenFilesDialog(allFiles, NULL); + + if (dialog->result() != QDialog::Accepted) + { + delete dialog; + return 0; + } + dialog->getFilesList(&files); + delete dialog; + QProgressDialog progress("Processing files...", "Cancel", 0, files.size()); progress.setWindowModality(Qt::WindowModal); diff --git a/doxygen.pro b/doxygen.pro index e29514d..12bf565 100644 --- a/doxygen.pro +++ b/doxygen.pro @@ -6,7 +6,8 @@ SOURCES += doxygenplugin.cpp \ doxygensettings.cpp \ doxygensettingsstruct.cpp \ doxygensettingswidget.cpp \ - doxygen.cpp + doxygen.cpp \ + doxygenfilesdialog.cpp HEADERS += doxygenplugin.h \ doxygen_global.h \ @@ -14,10 +15,12 @@ HEADERS += doxygenplugin.h \ doxygensettings.h \ doxygensettingsstruct.h \ doxygensettingswidget.h \ - doxygen.h + doxygen.h \ + doxygenfilesdialog.h FORMS += \ - doxygensettingswidget.ui + doxygensettingswidget.ui \ + doxygenfilesdialog.ui RESOURCES += doxygen.qrc diff --git a/doxygenfilesdialog.cpp b/doxygenfilesdialog.cpp new file mode 100644 index 0000000..6c4b0fb --- /dev/null +++ b/doxygenfilesdialog.cpp @@ -0,0 +1,65 @@ +#include "doxygenfilesdialog.h" +#include "ui_doxygenfilesdialog.h" + +#include +#include + +DoxygenFilesDialog::DoxygenFilesDialog(const QStringList &in, QWidget *parent) : + QDialog(parent), + ui(new Ui::DoxygenFilesDialog) +{ + ui->setupUi(this); + + QStringListIterator it(in); + + while (it.hasNext()) + { + QListWidgetItem *listItem = new QListWidgetItem(it.next()); + listItem->setCheckState(Qt::Checked); + ui->listWidget->addItem(listItem); + } + + connect(ui->b_all, SIGNAL(clicked(bool)), this, SLOT(checkAll())); + connect(ui->b_none, SIGNAL(clicked(bool)), this, SLOT(checkNone())); + connect(ui->b_cancel, SIGNAL(clicked(bool)), this, SLOT(reject())); + connect(ui->b_ok, SIGNAL(clicked(bool)), this, SLOT(accept())); + + this->exec(); +} + +DoxygenFilesDialog::~DoxygenFilesDialog() +{ + delete ui; +} + +uint DoxygenFilesDialog::getFilesList(QStringList *out) +{ + uint count = 0; + for (int i=0; i< ui->listWidget->count(); i++) + { + if (ui->listWidget->item(i)->checkState() == Qt::Checked) + { + out->append(ui->listWidget->item(i)->text()); + count++; + } + } + return count; +} + +void DoxygenFilesDialog::checkAll() +{ + for (int i=0; i< ui->listWidget->count(); i++) + { + if (ui->listWidget->item(i)->checkState() == Qt::Unchecked) + ui->listWidget->item(i)->setCheckState(Qt::Checked); + } +} + +void DoxygenFilesDialog::checkNone() +{ + for (int i=0; i< ui->listWidget->count(); i++) + { + if (ui->listWidget->item(i)->checkState() == Qt::Checked) + ui->listWidget->item(i)->setCheckState(Qt::Unchecked); + } +} diff --git a/doxygenfilesdialog.h b/doxygenfilesdialog.h new file mode 100644 index 0000000..b6a9947 --- /dev/null +++ b/doxygenfilesdialog.h @@ -0,0 +1,27 @@ +#ifndef DOXYGENFILESDIALOG_H +#define DOXYGENFILESDIALOG_H + +#include + +namespace Ui { +class DoxygenFilesDialog; +} + +class DoxygenFilesDialog : public QDialog +{ + Q_OBJECT + +public: + explicit DoxygenFilesDialog(const QStringList &in, QWidget *parent = 0); + ~DoxygenFilesDialog(); + uint getFilesList(QStringList *out); + +private: + Ui::DoxygenFilesDialog *ui; + +private slots: + void checkAll(); + void checkNone(); +}; + +#endif // DOXYGENFILESDIALOG_H diff --git a/doxygenfilesdialog.ui b/doxygenfilesdialog.ui new file mode 100644 index 0000000..236af0d --- /dev/null +++ b/doxygenfilesdialog.ui @@ -0,0 +1,93 @@ + + + DoxygenFilesDialog + + + Qt::ApplicationModal + + + + 0 + 0 + 400 + 300 + + + + Select files to document + + + true + + + + + + true + + + + + + + + 0 + 50 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Select All + + + + + + + Select None + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Ok + + + + + + + Cancel + + + + + + + + + + + diff --git a/doxygenplugin.cpp b/doxygenplugin.cpp index 9280f17..f4feb48 100644 --- a/doxygenplugin.cpp +++ b/doxygenplugin.cpp @@ -222,14 +222,9 @@ void DoxygenPlugin::documentSpecificProject() void DoxygenPlugin::documentCurrentProject() { - if (QMessageBox::question((QWidget*)this->parent(), - "Doxygen", "Document current project?", - QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) - { - uint count = Doxygen::instance()->documentCurrentProject(settings()); - QString msg; - this->externalString(msg.sprintf("Doxygen blocs generated: %u", count)); - } + uint count = Doxygen::instance()->documentCurrentProject(settings()); + QString msg; + this->externalString(msg.sprintf("Doxygen blocs generated: %u", count)); } bool DoxygenPlugin::buildDocumentation() // TODO: refactor