diff --git a/doxygen.cpp b/doxygen.cpp index 2db5d9c..1317eb1 100644 --- a/doxygen.cpp +++ b/doxygen.cpp @@ -23,33 +23,33 @@ #include "doxygenfilesdialog.h" #include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include -#include -#include #include #include -#include -#include #include +#include +#include +#include +#include using namespace CPlusPlus; using namespace ProjectExplorer; @@ -58,8 +58,8 @@ using namespace DoxyPlugin::Internal; Doxygen* Doxygen::m_instance = 0; -Doxygen::Doxygen(QObject *parent) : - QObject(parent) +Doxygen::Doxygen(QObject* parent) + : QObject(parent) { m_cancel = false; @@ -100,12 +100,11 @@ Doxygen* Doxygen::instance() // TODO, get rid of it. QStringList scopesForSymbol(const Symbol* symbol) { - const Scope *scope = symbol->asScope(); + const Scope* scope = symbol->asScope(); QStringList scopes; - if(symbol->isFunction()) - { - const Name *name = symbol->name(); + if (symbol->isFunction()) { + const Name* name = symbol->name(); Overview overview; overview.showArgumentNames = false; overview.showReturnTypes = false; @@ -113,13 +112,11 @@ QStringList scopesForSymbol(const Symbol* symbol) return scopes; } - for (; scope; scope = scope->enclosingScope()) - { - Symbol *owner = scope->memberAt(0); + for (; scope; scope = scope->enclosingScope()) { + Symbol* owner = scope->memberAt(0); - if (owner && owner->name() && ! scope->isEnum()) - { - const Name *name = owner->name(); + if (owner && owner->name() && !scope->isEnum()) { + const Name* name = owner->name(); Overview overview; overview.showArgumentNames = false; overview.showReturnTypes = false; @@ -129,18 +126,16 @@ QStringList scopesForSymbol(const Symbol* symbol) return scopes; } -Symbol* currentSymbol(Core::IEditor *editor) +Symbol* currentSymbol(Core::IEditor* editor) { - CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance(); - if (!modelManager) - { + CppTools::CppModelManager* modelManager = CppTools::CppModelManager::instance(); + if (!modelManager) { return 0; } const Snapshot snapshot = modelManager->snapshot(); Document::Ptr doc = snapshot.document(editor->document()->filePath()); - if (!doc) - { + if (!doc) { return 0; } @@ -149,38 +144,36 @@ Symbol* currentSymbol(Core::IEditor *editor) } // TODO: Recode it entirely. -bool Doxygen::documentEntity(const DoxygenSettingsStruct &DoxySettings, Core::IEditor *editor) +bool Doxygen::documentEntity(const DoxygenSettingsStruct& DoxySettings, Core::IEditor* editor) { // before continuing, test if the editor is actually showing a file. - if(!editor) + if (!editor) return false; // get the widget for later. - TextEditor::TextEditorWidget *editorWidget = qobject_cast( - editor->widget()); + TextEditor::TextEditorWidget* editorWidget = qobject_cast( + editor->widget()); // get our symbol - Symbol *lastSymbol = currentSymbol(editor); + Symbol* lastSymbol = currentSymbol(editor); editorWidget->gotoLineStart(); int lastLine = editor->currentLine(); int lastColumn = editor->currentColumn(); - while(lastSymbol - && (lastSymbol->line() != static_cast(lastLine) - || lastSymbol->column() != static_cast(lastColumn))) - { + while (lastSymbol + && (lastSymbol->line() != static_cast(lastLine) + || lastSymbol->column() != static_cast(lastColumn))) { //qDebug() << "lastSymbol: " << lastSymbol->line() << " " << lastSymbol->column(); //qDebug() << "lastLine: " << lastLine << " " << lastColumn; editorWidget->gotoNextWord(); // infinite loop prevention - if(lastLine == editor->currentLine() && lastColumn == editor->currentColumn()) + if (lastLine == editor->currentLine() && lastColumn == editor->currentColumn()) return false; lastLine = editor->currentLine(); lastColumn = editor->currentColumn(); lastSymbol = currentSymbol(editor); } //qDebug() << lastLine << " " << lastColumn; - if (!lastSymbol) - { + if (!lastSymbol) { return false; } @@ -191,13 +184,12 @@ bool Doxygen::documentEntity(const DoxygenSettingsStruct &DoxySettings, Core::IE QStringList lines(text.split(QRegExp("\n|\r\n|\r"))); // We check the 4 previous lines for comments block closing. - for (int i= 1; i <= 4; i++) - { + for (int i = 1; i <= 4; i++) { int prevLine = lastLine - i; - if (prevLine < 0) break; + if (prevLine < 0) + break; QString checkText(lines.at(prevLine)); - if (checkText.contains(commentClosing)) - { + if (checkText.contains(commentClosing)) { //qDebug() << "Duplicate found in" << editor->document()->filePath().toString() << prevLine; //qDebug() << checkText; return false; @@ -211,7 +203,7 @@ bool Doxygen::documentEntity(const DoxygenSettingsStruct &DoxySettings, Core::IE overview.showTemplateParameters = false; overview.showReturnTypes = true; overview.showFunctionSignatures = true; - const Name *name = lastSymbol->name(); + const Name* name = lastSymbol->name(); scopes.append(overview.prettyName(name)); //qDebug() << overview.prettyName(name); //qDebug() << overview.prettyType(lastSymbol->type(), name); @@ -230,24 +222,20 @@ bool Doxygen::documentEntity(const DoxygenSettingsStruct &DoxySettings, Core::IE indent = textList.at(0); // quickfix when calling the method on "};" (end class) or "}" (end namespace) - if(indent.contains(QRegExp("^\\};?"))) - { + if (indent.contains(QRegExp("^\\};?"))) { return false; } - if(indent.endsWith('~')) + if (indent.endsWith('~')) indent.chop(1); - if(lastSymbol->isClass()) - { + if (lastSymbol->isClass()) { docToWrite += indent + DoxySettings.DoxyComment.doxBegin; - if(DoxySettings.printBrief) - { + if (DoxySettings.printBrief) { docToWrite += indent + DoxySettings.DoxyComment.doxBrief; docToWrite += indent + DoxySettings.DoxyComment.doxEmptyLine; } - if(DoxySettings.verbosePrinting) - { + if (DoxySettings.verbosePrinting) { QString projectRoot = getProjectRoot(); QString fileNameStr = editor->document()->filePath().toString(); QString fileName = fileNameStr.remove(0, fileNameStr.lastIndexOf("/") + 1); @@ -255,32 +243,26 @@ bool Doxygen::documentEntity(const DoxygenSettingsStruct &DoxySettings, Core::IE docToWrite += indent + DoxySettings.DoxyComment.doxNewLine + "class " + overview.prettyName(name) + " " + fileName + " \"" + fileNameProj + "\"\n"; } docToWrite += indent + DoxySettings.DoxyComment.doxEnding; - } - else if(lastSymbol->isTypedef()) - { + } else if (lastSymbol->isTypedef()) { docToWrite += indent + DoxySettings.DoxyComment.doxBegin; - if(DoxySettings.printBrief) - { + if (DoxySettings.printBrief) { docToWrite += indent + DoxySettings.DoxyComment.doxBrief; docToWrite += indent + DoxySettings.DoxyComment.doxEmptyLine; } - if(DoxySettings.verbosePrinting) + if (DoxySettings.verbosePrinting) docToWrite += indent + DoxySettings.DoxyComment.doxNewLine + "typedef " + overview.prettyName(name); docToWrite += indent + DoxySettings.DoxyComment.doxEnding; - } - else if(lastSymbol->isEnum()) - { + } else if (lastSymbol->isEnum()) { docToWrite += indent + DoxySettings.DoxyComment.doxBegin; - if(DoxySettings.printBrief) + if (DoxySettings.printBrief) docToWrite += indent + DoxySettings.DoxyComment.doxBrief; docToWrite += indent + DoxySettings.DoxyComment.doxEmptyLine; - if(DoxySettings.verbosePrinting) + if (DoxySettings.verbosePrinting) docToWrite += indent + DoxySettings.DoxyComment.doxNewLine + "enum " + overview.prettyName(name) + "\n"; docToWrite += indent + DoxySettings.DoxyComment.doxEnding; } // Here comes the bitch. - else if(lastSymbol->isDeclaration() || lastSymbol->isFunction()) - { + else if (lastSymbol->isDeclaration() || lastSymbol->isFunction()) { overview.showArgumentNames = true; overview.showReturnTypes = false; overview.showDefaultArguments = false; @@ -289,36 +271,29 @@ bool Doxygen::documentEntity(const DoxygenSettingsStruct &DoxySettings, Core::IE QString arglist = overview.prettyType(lastSymbol->type(), name); docToWrite += indent + DoxySettings.DoxyComment.doxBegin; - if(DoxySettings.printBrief) - { + if (DoxySettings.printBrief) { docToWrite += indent + DoxySettings.DoxyComment.doxBrief; docToWrite += indent + DoxySettings.DoxyComment.doxEmptyLine; } // if variable, do it quickly... - if(!arglist.contains('(')) - { - if(DoxySettings.shortVarDoc) - { + if (!arglist.contains('(')) { + if (DoxySettings.shortVarDoc) { printAtEnd = true; docToWrite = DoxySettings.DoxyComment.doxShortVarDoc + "TODO: describe" + DoxySettings.DoxyComment.doxShortVarDocEnd; - } - else - { - if(DoxySettings.verbosePrinting) + } else { + if (DoxySettings.verbosePrinting) docToWrite += indent + DoxySettings.DoxyComment.doxNewLine + "var " + overview.prettyName(name) + "\n" + indent + DoxySettings.DoxyComment.doxEnding; else docToWrite += indent + DoxySettings.DoxyComment.doxEmptyLine + indent + DoxySettings.DoxyComment.doxEnding; } - } - else - { + } else { // Never noticed it before, a useless comment block because of the Q_OBJECT macro // so let's just ignore that will we? - if(overview.prettyName(name) == "qt_metacall") + if (overview.prettyName(name) == "qt_metacall") return false; - if(DoxySettings.verbosePrinting) + if (DoxySettings.verbosePrinting) docToWrite += indent + DoxySettings.DoxyComment.doxNewLine + "fn " + overview.prettyName(name) + "\n"; // Check parameters @@ -328,12 +303,11 @@ bool Doxygen::documentEntity(const DoxygenSettingsStruct &DoxySettings, Core::IE QStringList args = arglist.trimmed().split(',', QString::SkipEmptyParts); - Q_FOREACH(QString singleArg, args) - { + Q_FOREACH (QString singleArg, args) { singleArg.remove(QRegExp("\\s*=.*")); // FIXME probably don't need the * after \\s but... - singleArg.replace("*",""); - singleArg.replace("&",""); - docToWrite += indent + DoxySettings.DoxyComment.doxNewLine + "param " + singleArg.section(' ', -1) + "\n"; + singleArg.replace("*", ""); + singleArg.replace("&", ""); + docToWrite += indent + DoxySettings.DoxyComment.doxNewLine + "param " + singleArg.section(' ', -1) + "\n"; } // And now check the return type @@ -346,28 +320,25 @@ bool Doxygen::documentEntity(const DoxygenSettingsStruct &DoxySettings, Core::IE arglist = overview.prettyType(lastSymbol->type(), name); // FIXME this check is just insane... - if( arglist.contains(' ') - && ((lastSymbol->isFunction() && !overview.prettyName(name).contains("::~")) - || (lastSymbol->isDeclaration() && overview.prettyName(name).at(0) != '~') )) - { + if (arglist.contains(' ') + && ((lastSymbol->isFunction() && !overview.prettyName(name).contains("::~")) + || (lastSymbol->isDeclaration() && overview.prettyName(name).at(0) != '~'))) { QRegExp rx("void *"); rx.setPatternSyntax(QRegExp::Wildcard); - if(!rx.exactMatch(arglist)) - { + if (!rx.exactMatch(arglist)) { // dirty workarround int last; - if(arglist.contains('>')) + if (arglist.contains('>')) last = arglist.lastIndexOf('>') + 1; else last = arglist.lastIndexOf(' '); arglist.chop(arglist.size() - last); - if(DoxySettings.automaticReturnType == false) - { + if (DoxySettings.automaticReturnType == false) { arglist.clear(); } - docToWrite += indent + DoxySettings.DoxyComment.doxNewLine + "return " + arglist + "\n"; + docToWrite += indent + DoxySettings.DoxyComment.doxNewLine + "return " + arglist + "\n"; } } docToWrite += indent + DoxySettings.DoxyComment.doxEnding; @@ -375,9 +346,8 @@ bool Doxygen::documentEntity(const DoxygenSettingsStruct &DoxySettings, Core::IE } // Write the documentation in the editor - if (editorWidget) - { - if(printAtEnd) + if (editorWidget) { + if (printAtEnd) editorWidget->moveCursor(QTextCursor::EndOfLine); else editorWidget->moveCursor(QTextCursor::StartOfBlock); @@ -385,18 +355,18 @@ bool Doxygen::documentEntity(const DoxygenSettingsStruct &DoxySettings, Core::IE editorWidget->insertPlainText(docToWrite); return true; } - return false; + return false; } -bool Doxygen::addFileComment(const DoxygenSettingsStruct &DoxySettings, Core::IEditor *editor) +bool Doxygen::addFileComment(const DoxygenSettingsStruct& DoxySettings, Core::IEditor* editor) { // before continuing, test if the editor is actually showing a file. - if(!editor) + if (!editor) return false; // get the widget for later. - TextEditor::TextEditorWidget *editorWidget = qobject_cast( - editor->widget()); + TextEditor::TextEditorWidget* editorWidget = qobject_cast( + editor->widget()); QString text = DoxySettings.DoxyComment.doxBegin + DoxySettings.DoxyComment.doxNewLine; text += "file " + editor->document()->filePath().fileName() + "\n"; @@ -411,68 +381,58 @@ bool Doxygen::addFileComment(const DoxygenSettingsStruct &DoxySettings, Core::IE return true; } -void Doxygen::addSymbol(const CPlusPlus::Symbol* symbol, QList &symmap) +void Doxygen::addSymbol(const CPlusPlus::Symbol* symbol, QList& symmap) { - if(!symbol || symbol->isBaseClass() || symbol->isGenerated()) + if (!symbol || symbol->isBaseClass() || symbol->isGenerated()) return; - if(symbol->isArgument() - || symbol->isFunction() - || symbol->isDeclaration() - || symbol->isEnum()) - { + if (symbol->isArgument() + || symbol->isFunction() + || symbol->isDeclaration() + || symbol->isEnum()) { symmap.append(symbol); return; - } - else if(symbol->isClass()) - { + } else if (symbol->isClass()) { symmap.append(symbol); } const CPlusPlus::Scope* scopedSymbol = symbol->asScope(); - if(scopedSymbol) - { + if (scopedSymbol) { int nbmembers = scopedSymbol->memberCount(); - for(int i=0; imemberAt(i), symmap); } } } -uint Doxygen::documentFile(const DoxygenSettingsStruct &DoxySettings, Core::IEditor *editor) +uint Doxygen::documentFile(const DoxygenSettingsStruct& DoxySettings, Core::IEditor* editor) { // before continuing, test if the editor is actually showing a file. - if(!editor) - { + if (!editor) { //qDebug() << "No editor"; return 0; } m_cancel = false; - CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance(); + CppTools::CppModelManager* modelManager = CppTools::CppModelManager::instance(); //ExtensionSystem::PluginManager::instance()->getObject(); - if(!modelManager) - { + if (!modelManager) { //qDebug() << "No modelManager"; return 0; } const Snapshot snapshot = modelManager->snapshot(); Document::Ptr doc = snapshot.document(editor->document()->filePath()); - if(!doc) - { + if (!doc) { //qDebug() << "No document"; return 0; } // TODO : check int globalSymbols = doc->globalSymbolCount(); - if(!globalSymbols) - { - if(DoxySettings.fileCommentsEnabled) - { + if (!globalSymbols) { + if (DoxySettings.fileCommentsEnabled) { addFileComment(DoxySettings, editor); } //qDebug() << "No global symbols"; @@ -480,11 +440,9 @@ uint Doxygen::documentFile(const DoxygenSettingsStruct &DoxySettings, Core::IEdi } // check that as well... - Scope* scope = doc->scopeAt(0,0); - if(!scope) - { - if(DoxySettings.fileCommentsEnabled) - { + Scope* scope = doc->scopeAt(0, 0); + if (!scope) { + if (DoxySettings.fileCommentsEnabled) { addFileComment(DoxySettings, editor); } //qDebug() << "No scope"; @@ -494,57 +452,51 @@ uint Doxygen::documentFile(const DoxygenSettingsStruct &DoxySettings, Core::IEdi unsigned symbolcount = scope->memberCount(); QList symmap; - for(unsigned i=0; i < symbolcount; ++i) + for (unsigned i = 0; i < symbolcount; ++i) addSymbol(scope->memberAt(i), symmap); // sanity check, it's expensive and ugly but the result isn't pretty on some codes if not done. - unsigned oldline=0; - Q_FOREACH(const Symbol* sym, symmap) - { - if(sym->line() == oldline) + unsigned oldline = 0; + Q_FOREACH (const Symbol* sym, symmap) { + if (sym->line() == oldline) symmap.removeOne(sym); oldline = sym->line(); } const int symCount = symmap.size(); const int symMin = 100; - TextEditor::TextEditorWidget *editorWidget = qobject_cast(editor->widget()); - QString fileName("Processing "+editor->document()->filePath().fileName()+"..."); + TextEditor::TextEditorWidget* editorWidget = qobject_cast(editor->widget()); + QString fileName("Processing " + editor->document()->filePath().fileName() + "..."); uint count = 0; emit message(fileName); - if (symCount > symMin) - { + if (symCount > symMin) { m_fileProgress->setLabelText(fileName); m_fileProgress->setMaximum(symCount); m_fileProgress->setValue(0); m_fileProgress->show(); } - if (editorWidget) - { + if (editorWidget) { QList::iterator it = symmap.end(); - for (int i = 0 ; it != symmap.begin(); --it) - { + for (int i = 0; it != symmap.begin(); --it) { if (symCount > symMin && i++ % 20 == 0) // Every n occurences { - if (m_cancel) - { + if (m_cancel) { break; } m_fileProgress->setValue(i); m_fileProgress->update(); } - const Symbol* sym = *(it-1); + const Symbol* sym = *(it - 1); editorWidget->gotoLine(sym->line()); if (documentEntity(DoxySettings, editor)) count++; } - if(DoxySettings.fileCommentsEnabled) - { + if (DoxySettings.fileCommentsEnabled) { if (addFileComment(DoxySettings, editor)) count++; } @@ -557,12 +509,12 @@ uint Doxygen::documentFile(const DoxygenSettingsStruct &DoxySettings, Core::IEdi } // TODO: fix this! Unused at the moment. -uint Doxygen::documentSpecificProject(const DoxygenSettingsStruct &DoxySettings) +uint Doxygen::documentSpecificProject(const DoxygenSettingsStruct& DoxySettings) { return documentProject(ProjectExplorer::SessionManager::startupProject(), DoxySettings); } -uint Doxygen::documentCurrentProject(const DoxygenSettingsStruct &DoxySettings) +uint Doxygen::documentCurrentProject(const DoxygenSettingsStruct& DoxySettings) { return documentProject(ProjectExplorer::ProjectTree::currentProject(), DoxySettings); } @@ -573,29 +525,28 @@ void Doxygen::cancelOperation() emit message("Operation canceled"); } -uint Doxygen::documentProject(ProjectExplorer::Project *p, const DoxygenSettingsStruct &DoxySettings) +uint Doxygen::documentProject(ProjectExplorer::Project* p, const DoxygenSettingsStruct& DoxySettings) { // prevent a crash if user launches this command with no project opened // You don't need to have an editor open for that. if (!p) { QMessageBox::warning((QWidget*)parent(), - tr("Doxygen"), - tr("You don't have any current project."), - QMessageBox::Close, QMessageBox::NoButton); + tr("Doxygen"), + tr("You don't have any current project."), + QMessageBox::Close, QMessageBox::NoButton); return 0; } uint count = 0; m_cancel = false; - Core::EditorManager *editorManager = Core::EditorManager::instance(); + Core::EditorManager* editorManager = Core::EditorManager::instance(); QStringList files; - DoxygenFilesDialog *dialog = new DoxygenFilesDialog(NULL); + DoxygenFilesDialog* dialog = new DoxygenFilesDialog(NULL); dialog->initFileTree(p->rootProjectNode()); - if (dialog->exec() != QDialog::Accepted) - { + if (dialog->exec() != QDialog::Accepted) { delete dialog; return 0; } @@ -605,63 +556,50 @@ uint Doxygen::documentProject(ProjectExplorer::Project *p, const DoxygenSettings m_projectProgress->setMaximum(files.size()); m_projectProgress->show(); - for(int i = 0 ; i < files.size() ; ++i) - { + for (int i = 0; i < files.size(); ++i) { bool documented = false; m_projectProgress->setValue(i); //qDebug() << "Current file:" << i; - if(m_cancel) { + if (m_cancel) { break; } QFileInfo fileInfo(files[i]); QString fileExtension = fileInfo.suffix(); //qDebug() << "Current file:" << files.at(i); - if( - ( - (DoxySettings.fcomment == headers /*|| DoxySettings.fcomment == bothqt*/ || - DoxySettings.fcomment == all) - && (fileExtension == "hpp" || fileExtension == "h") - ) - || ( - (DoxySettings.fcomment == implementations /*|| DoxySettings.fcomment == bothqt*/ || - DoxySettings.fcomment == all) - && (fileExtension == "cpp" || fileExtension == "c") - ) - ) { /*|| ( //TODO: add documentation of QML files (see doxyqml comments interpretation) + if ( + ( + (DoxySettings.fcomment == headers /*|| DoxySettings.fcomment == bothqt*/ || DoxySettings.fcomment == all) + && (fileExtension == "hpp" || fileExtension == "h")) + || ((DoxySettings.fcomment == implementations /*|| DoxySettings.fcomment == bothqt*/ || DoxySettings.fcomment == all) + && (fileExtension == "cpp" || fileExtension == "c"))) { /*|| ( //TODO: add documentation of QML files (see doxyqml comments interpretation) (DoxySettings.fcomment == qml || DoxySettings.fcomment == all) && fileExtension == "qml" ) ) {*/ - Core::IEditor *editor = editorManager->openEditor(files[i], Core::Id(), - Core::EditorManager::DoNotChangeCurrentEditor - | Core::EditorManager::IgnoreNavigationHistory - | Core::EditorManager::DoNotMakeVisible); - if(editor) - { + Core::IEditor* editor = editorManager->openEditor(files[i], Core::Id(), + Core::EditorManager::DoNotChangeCurrentEditor + | Core::EditorManager::IgnoreNavigationHistory + | Core::EditorManager::DoNotMakeVisible); + if (editor) { documented = true; count += documentFile(DoxySettings, editor); } } - if(DoxySettings.fileCommentsEnabled && documented == false) - { + if (DoxySettings.fileCommentsEnabled && documented == false) { bool commentFile = false; //qDebug() << "FileCommentHeaders: " << DoxySettings.fileCommentHeaders; //qDebug() << "FileCommentImpl: " << DoxySettings.fileCommentImpl; - if(DoxySettings.fileCommentHeaders && (fileExtension == "hpp" || fileExtension == "h")) - { + if (DoxySettings.fileCommentHeaders && (fileExtension == "hpp" || fileExtension == "h")) { commentFile = true; - } - else if(DoxySettings.fileCommentImpl && (fileExtension == "cpp" || fileExtension == "c")) - { + } else if (DoxySettings.fileCommentImpl && (fileExtension == "cpp" || fileExtension == "c")) { commentFile = true; } - if(commentFile) - { - Core::IEditor *editor = editorManager->openEditor(files[i]); - if(editor) + if (commentFile) { + Core::IEditor* editor = editorManager->openEditor(files[i]); + if (editor) count += addFileComment(DoxySettings, editor); } } @@ -679,11 +617,9 @@ QString Doxygen::getProjectRoot() { QString projectRoot; Project* proj = ProjectTree::currentProject(); - if(proj) - { + if (proj) { projectRoot = proj->projectDirectory().toString() + "/"; } return projectRoot; } - diff --git a/doxygen.pro b/doxygen.pro index 3da0ac0..f2af220 100644 --- a/doxygen.pro +++ b/doxygen.pro @@ -28,12 +28,12 @@ RESOURCES += doxygen.qrc ## set the QTC_SOURCE environment variable to override the setting here QTCREATOR_SOURCES = $$(QTC_SOURCE) -unix:isEmpty(QTCREATOR_SOURCES):QTCREATOR_SOURCES=$$(HOME)/src/qt-creator-opensource-src-4.2.0 -win32:isEmpty(QTCREATOR_SOURCES):QTCREATOR_SOURCES=D:\src\qt-creator-opensource-src-4.2.0 +unix:isEmpty(QTCREATOR_SOURCES):QTCREATOR_SOURCES=$$(HOME)/src/qt-creator-opensource-src-4.3.0 +win32:isEmpty(QTCREATOR_SOURCES):QTCREATOR_SOURCES=D:\src\qt-creator-opensource-src-4.3.0 ## set the QTC_BUILD environment variable to override the setting here IDE_BUILD_TREE = $$(QTC_BUILD) -unix:isEmpty(IDE_BUILD_TREE):IDE_BUILD_TREE=$$(HOME)/qtcreator-4.2.0 +unix:isEmpty(IDE_BUILD_TREE):IDE_BUILD_TREE=$$(HOME)/qtcreator-4.3.0 win32:isEmpty(IDE_BUILD_TREE):IDE_BUILD_TREE=D:\src\build-qtcreator-5_6_0_msvc2013-Release ## set the QTC_LIB_BASENAME environment variable to override the setting here diff --git a/doxygenfilesdialog.cpp b/doxygenfilesdialog.cpp index eefe882..0cb66b5 100644 --- a/doxygenfilesdialog.cpp +++ b/doxygenfilesdialog.cpp @@ -1,200 +1,161 @@ #include "doxygenfilesdialog.h" #include "ui_doxygenfilesdialog.h" -DoxygenFilesDialog::DoxygenFilesDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::DoxygenFilesDialog) +DoxygenFilesDialog::DoxygenFilesDialog(QWidget* parent) + : QDialog(parent) + , ui(new Ui::DoxygenFilesDialog) { - ui->setupUi(this); + ui->setupUi(this); - 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())); + 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())); - connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(updateChecks(QTreeWidgetItem *, int))); + connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(updateChecks(QTreeWidgetItem*, int))); } DoxygenFilesDialog::~DoxygenFilesDialog() { - delete ui; + delete ui; } -void DoxygenFilesDialog::initFileTree(ProjectExplorer::Node *rootNode) +void DoxygenFilesDialog::initFileTree(ProjectExplorer::Node* rootNode) { - createLeaf(rootNode, new QTreeWidgetItem(ui->treeWidget, QStringList(rootNode->displayName()))); - ui->treeWidget->expandAll(); - ui->treeWidget->setItemsExpandable(false); + createLeaf(rootNode, new QTreeWidgetItem(ui->treeWidget, QStringList(rootNode->displayName()))); + ui->treeWidget->expandAll(); } -void DoxygenFilesDialog::createLeaf(ProjectExplorer::Node *parentNode, QTreeWidgetItem *parentItem) +void DoxygenFilesDialog::createLeaf(ProjectExplorer::Node* parentNode, QTreeWidgetItem* parentItem) { - parentItem->setCheckState(0, Qt::Checked); + parentItem->setCheckState(0, Qt::Checked); - if (parentNode->asFolderNode()) - { - ProjectExplorer::FolderNode *currentFolderNode = parentNode->asFolderNode(); + if (parentNode->asFolderNode()) { + ProjectExplorer::FolderNode* currentFolderNode = parentNode->asFolderNode(); parentItem->setIcon(0, currentFolderNode->icon()); - foreach(ProjectExplorer::FileNode *fileNode, currentFolderNode->fileNodes()) - { - QString fileName = fileNode->filePath().toString(); - - if ((QRegExp("\\.(h|hpp|c|cpp)$").indexIn(fileName)) != -1) - { - QTreeWidgetItem *child = new QTreeWidgetItem(parentItem, QStringList(fileName)); - child->setCheckState(0, Qt::Checked); - parentItem->addChild(child); - } - } - - foreach(ProjectExplorer::FolderNode * folderNode, currentFolderNode->subFolderNodes()) - { - createLeaf(folderNode, new QTreeWidgetItem(parentItem, QStringList(folderNode->displayName()))); - } - } - else if (parentNode->asProjectNode()) - { - ProjectExplorer::ProjectNode *currentProjectNode = parentNode->asProjectNode(); + foreach (ProjectExplorer::FileNode* fileNode, currentFolderNode->fileNodes()) { + QString fileName = fileNode->filePath().toString(); + + if ((QRegExp("\\.(h|hpp|c|cpp)$").indexIn(fileName)) != -1) { + QTreeWidgetItem* child = new QTreeWidgetItem(parentItem, QStringList(fileName)); + child->setCheckState(0, Qt::Checked); + parentItem->addChild(child); + } + } + + foreach (ProjectExplorer::FolderNode* folderNode, currentFolderNode->folderNodes()) { + createLeaf(folderNode, new QTreeWidgetItem(parentItem, QStringList(folderNode->displayName()))); + } + } else if (parentNode->asProjectNode()) { + ProjectExplorer::ProjectNode* currentProjectNode = parentNode->asProjectNode(); parentItem->setIcon(0, currentProjectNode->icon()); - foreach(ProjectExplorer::FileNode *fileNode, currentProjectNode->fileNodes()) - { - QString fileName = fileNode->filePath().toString(); - - if ((QRegExp("\\.(h|hpp|c|cpp)$").indexIn(fileName)) != -1) - { - QTreeWidgetItem *child = new QTreeWidgetItem(parentItem, QStringList(fileName)); - child->setCheckState(0, Qt::Checked); - parentItem->addChild(child); - } - } - - foreach(ProjectExplorer::FolderNode *folderNode, currentProjectNode->subFolderNodes()) - { - createLeaf(folderNode, new QTreeWidgetItem(parentItem, QStringList(folderNode->displayName()))); - } - - foreach(ProjectExplorer::ProjectNode *projectNode, currentProjectNode->subProjectNodes()) - { - createLeaf(projectNode, new QTreeWidgetItem(parentItem, QStringList(projectNode->displayName()))); - } - } - - if (parentItem->childCount() == 0) - { - delete(parentItem); - } + foreach (ProjectExplorer::FileNode* fileNode, currentProjectNode->fileNodes()) { + QString fileName = fileNode->filePath().toString(); + + if ((QRegExp("\\.(h|hpp|c|cpp)$").indexIn(fileName)) != -1) { + QTreeWidgetItem* child = new QTreeWidgetItem(parentItem, QStringList(fileName)); + child->setCheckState(0, Qt::Checked); + parentItem->addChild(child); + } + } + + foreach (ProjectExplorer::FolderNode* folderNode, currentProjectNode->folderNodes()) { + createLeaf(folderNode, new QTreeWidgetItem(parentItem, QStringList(folderNode->displayName()))); + } + + createLeaf(currentProjectNode, new QTreeWidgetItem(parentItem, QStringList(currentProjectNode->displayName()))); + } + + if (parentItem->childCount() == 0) { + delete (parentItem); + } } -uint DoxygenFilesDialog::getFilesList(QTreeWidgetItem *parent, QStringList *out, int count) +uint DoxygenFilesDialog::getFilesList(QTreeWidgetItem* parent, QStringList* out, int count) { - if (!parent->childCount()) - { - if (parent->checkState(0) == Qt::Checked) - { - out->append(parent->text(0)); - count++; - } - } - else - { - for (int i = 0; i < parent->childCount(); i++) - { - getFilesList(parent->child(i), out, count); - } - } - - return count; + if (!parent->childCount()) { + if (parent->checkState(0) == Qt::Checked) { + out->append(parent->text(0)); + count++; + } + } else { + for (int i = 0; i < parent->childCount(); i++) { + getFilesList(parent->child(i), out, count); + } + } + + return count; } -uint DoxygenFilesDialog::getFilesList(QStringList *out) +uint DoxygenFilesDialog::getFilesList(QStringList* out) { - uint count = 0; - for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) - { - getFilesList(ui->treeWidget->topLevelItem(i), out, count); - } - return count; + uint count = 0; + for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) { + getFilesList(ui->treeWidget->topLevelItem(i), out, count); + } + return count; } -void DoxygenFilesDialog::changeCheckState(QTreeWidgetItem *parent, Qt::CheckState state) +void DoxygenFilesDialog::changeCheckState(QTreeWidgetItem* parent, Qt::CheckState state) { - if (!parent->childCount()) - { - if (parent->checkState(0) != state) - { - parent->setCheckState(0, state); - } - } - else - { - for (int i = 0; i < parent->childCount(); i++) - { - changeCheckState(parent->child(i), state); - } - } + if (!parent->childCount()) { + if (parent->checkState(0) != state) { + parent->setCheckState(0, state); + } + } else { + for (int i = 0; i < parent->childCount(); i++) { + changeCheckState(parent->child(i), state); + } + } } void DoxygenFilesDialog::checkAll() { - for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) - { - changeCheckState( ui->treeWidget->topLevelItem(i), Qt::Checked); - } + for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) { + changeCheckState(ui->treeWidget->topLevelItem(i), Qt::Checked); + } } void DoxygenFilesDialog::checkNone() { - for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) - { - changeCheckState(ui->treeWidget->topLevelItem(i), Qt::Unchecked); - } + for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) { + changeCheckState(ui->treeWidget->topLevelItem(i), Qt::Unchecked); + } } -void DoxygenFilesDialog::updateChecks(QTreeWidgetItem *item, int column) +void DoxygenFilesDialog::updateChecks(QTreeWidgetItem* item, int column) { - bool diff = false; - - if (column != 0 && column != -1) - { - return; - } - - if (item->childCount() != 0 && item->checkState(0) != Qt::PartiallyChecked && column != -1) - { - Qt::CheckState checkState = item->checkState(0); - for (int i = 0; i < item->childCount(); ++i) - { - item->child(i)->setCheckState(0, checkState); - } - } - else if (item->childCount() == 0 || column == -1) - { - if (item->parent() == 0) - { - return; - } - for (int j = 0; j < item->parent()->childCount(); ++j) - { - if (j != item->parent()->indexOfChild(item) && item->checkState(0) != item->parent()->child(j)->checkState(0)) - { - diff = true; - } - } - if (diff) - { - item->parent()->setCheckState(0, Qt::PartiallyChecked); - } - else - { - item->parent()->setCheckState(0, item->checkState(0)); - } - if (item->parent() != 0) - { - updateChecks(item->parent(), -1); - } - } + bool diff = false; + + if (column != 0 && column != -1) { + return; + } + + if (item->childCount() != 0 && item->checkState(0) != Qt::PartiallyChecked && column != -1) { + Qt::CheckState checkState = item->checkState(0); + for (int i = 0; i < item->childCount(); ++i) { + item->child(i)->setCheckState(0, checkState); + } + } else if (item->childCount() == 0 || column == -1) { + if (item->parent() == 0) { + return; + } + for (int j = 0; j < item->parent()->childCount(); ++j) { + if (j != item->parent()->indexOfChild(item) && item->checkState(0) != item->parent()->child(j)->checkState(0)) { + diff = true; + } + } + if (diff) { + item->parent()->setCheckState(0, Qt::PartiallyChecked); + } else { + item->parent()->setCheckState(0, item->checkState(0)); + } + if (item->parent() != 0) { + updateChecks(item->parent(), -1); + } + } } diff --git a/doxygenplugin.cpp b/doxygenplugin.cpp index f607519..73b76e5 100644 --- a/doxygenplugin.cpp +++ b/doxygenplugin.cpp @@ -20,39 +20,39 @@ **/ #include "doxygenplugin.h" -#include "doxygenconstants.h" #include "doxygen.h" +#include "doxygenconstants.h" -#include -#include +#include #include #include -#include #include -#include #include +#include +#include +#include #include #include #include #include -#include #include #include +#include +#include +#include #include #include -#include -#include #include -#include +#include +#include #include #include -#include -#include -#include -#include +#include #include +#include +#include #include @@ -61,16 +61,16 @@ using namespace DoxyPlugin; using namespace DoxyPlugin::Internal; // Timeout for building documentation -enum { doxygenTimeOut = 120}; +enum { doxygenTimeOut = 120 }; -static const char CMD_ID_DOXYGEN_MAINVIEW[] = "Doxygen.MainView"; -static const char CMD_ID_DOXYGEN_MENU[] = "Doxygen.Menu"; -static const char CMD_ID_CREATEDOCUMENTATION[] = "Doxygen.CreateDocumentation"; -static const char CMD_ID_DOCUMENTFILE[] = "Doxygen.DocumentFile"; -static const char CMD_ID_DOCUMENTOPENEDPROJECT[] = "Doxygen.DocumentOpenedProject"; -static const char CMD_ID_DOCUMENTACTIVEPROJECT[] = "Doxygen.DocumentActiveProject"; -static const char CMD_ID_BUILDDOCUMENTATION[] = "Doxygen.BuildDocumentation"; -static const char CMD_ID_DOXYFILEWIZARD[] = "Doxygen.RunWizard"; +static const char CMD_ID_DOXYGEN_MAINVIEW[] = "Doxygen.MainView"; +static const char CMD_ID_DOXYGEN_MENU[] = "Doxygen.Menu"; +static const char CMD_ID_CREATEDOCUMENTATION[] = "Doxygen.CreateDocumentation"; +static const char CMD_ID_DOCUMENTFILE[] = "Doxygen.DocumentFile"; +static const char CMD_ID_DOCUMENTOPENEDPROJECT[] = "Doxygen.DocumentOpenedProject"; +static const char CMD_ID_DOCUMENTACTIVEPROJECT[] = "Doxygen.DocumentActiveProject"; +static const char CMD_ID_BUILDDOCUMENTATION[] = "Doxygen.BuildDocumentation"; +static const char CMD_ID_DOXYFILEWIZARD[] = "Doxygen.RunWizard"; DoxygenPlugin* DoxygenPlugin::m_instance = 0; @@ -86,7 +86,7 @@ DoxygenPlugin::~DoxygenPlugin() m_instance = 0; } -bool DoxygenPlugin::initialize(const QStringList &arguments, QString *errorString) +bool DoxygenPlugin::initialize(const QStringList& arguments, QString* errorString) { // Register objects in the plugin manager's object pool // Load settings @@ -106,35 +106,35 @@ bool DoxygenPlugin::initialize(const QStringList &arguments, QString *errorStrin m_settings = new DoxygenSettings; addAutoReleasedObject(m_settings); - Core::ActionManager *am = Core::ActionManager::instance(); + Core::ActionManager* am = Core::ActionManager::instance(); Core::Context globalcontext(C_GLOBAL); //Core::Context context(CMD_ID_DOXYGEN_MAINVIEW); - Core::ActionContainer *toolsContainer = am->actionContainer(Core::Constants::M_TOOLS); - Core::ActionContainer *doxygenMenu = am->createMenu(Core::Id(CMD_ID_DOXYGEN_MENU)); + Core::ActionContainer* toolsContainer = am->actionContainer(Core::Constants::M_TOOLS); + Core::ActionContainer* doxygenMenu = am->createMenu(Core::Id(CMD_ID_DOXYGEN_MENU)); doxygenMenu->menu()->setTitle(tr("&Doxygen")); toolsContainer->addMenu(doxygenMenu); // put action in our own menu in "Tools" // create documentation for symbol under cursor - Core::Command *command; - m_doxygenCreateDocumentationAction = new QAction(tr("Document current entity"), this); + Core::Command* command; + m_doxygenCreateDocumentationAction = new QAction(tr("Document current entity"), this); command = am->registerAction(m_doxygenCreateDocumentationAction, CMD_ID_CREATEDOCUMENTATION, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F9"))); connect(m_doxygenCreateDocumentationAction, SIGNAL(triggered(bool)), this, SLOT(documentEntity())); doxygenMenu->addAction(command); // Don't forget the contextual menu - Core::ActionContainer *contextMenu= am->createMenu(CppEditor::Constants::M_CONTEXT); + Core::ActionContainer* contextMenu = am->createMenu(CppEditor::Constants::M_CONTEXT); contextMenu->addAction(command); // create documentation for a whole file - m_doxygenDocumentFileAction = new QAction(tr("Document current file"), this); + m_doxygenDocumentFileAction = new QAction(tr("Document current file"), this); command = am->registerAction(m_doxygenDocumentFileAction, CMD_ID_DOCUMENTFILE, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F5"))); connect(m_doxygenDocumentFileAction, SIGNAL(triggered(bool)), this, SLOT(documentFile())); doxygenMenu->addAction(command); -/* + /* // create documentation for a whole project of the currently opened file m_doxygenDocumentOpenedProjectAction = new QAction(tr("Document whole project of opened file"), this); command = am->registerAction(m_doxygenDocumentOpenedProjectAction, @@ -146,17 +146,17 @@ bool DoxygenPlugin::initialize(const QStringList &arguments, QString *errorStrin doxygenMenu->addAction(command); */ // create documentation for a whole project - m_doxygenDocumentActiveProjectAction = new QAction(tr("Document current project"), this); + m_doxygenDocumentActiveProjectAction = new QAction(tr("Document current project"), this); command = am->registerAction(m_doxygenDocumentActiveProjectAction, - CMD_ID_DOCUMENTACTIVEPROJECT, globalcontext); + CMD_ID_DOCUMENTACTIVEPROJECT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F8"))); connect(m_doxygenDocumentActiveProjectAction, SIGNAL(triggered(bool)), - this, SLOT(documentCurrentProject())); + this, SLOT(documentCurrentProject())); doxygenMenu->addAction(command); // "compile" documentation action - m_doxygenBuildDocumentationAction = new QAction(tr("Build Doxygen Documentation"), this); + m_doxygenBuildDocumentationAction = new QAction(tr("Build Doxygen Documentation"), this); command = am->registerAction(m_doxygenBuildDocumentationAction, CMD_ID_BUILDDOCUMENTATION, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F4"))); @@ -164,7 +164,7 @@ bool DoxygenPlugin::initialize(const QStringList &arguments, QString *errorStrin doxygenMenu->addAction(command); // edit Doxyfile action - m_doxygenDoxyfileWizardAction = new QAction(tr("Edit Doxyfile"), this); + m_doxygenDoxyfileWizardAction = new QAction(tr("Edit Doxyfile"), this); command = am->registerAction(m_doxygenDoxyfileWizardAction, CMD_ID_DOXYFILEWIZARD, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F6"))); @@ -176,19 +176,19 @@ bool DoxygenPlugin::initialize(const QStringList &arguments, QString *errorStrin connect(dox, SIGNAL(message(QString)), this, SLOT(externalString(QString))); - connect(this, SIGNAL(doxyDocumentEntity(DoxygenSettingsStruct,Core::IEditor*)), - dox, SLOT(documentEntity(DoxygenSettingsStruct,Core::IEditor*))); - connect(this, SIGNAL(doxyDocumentFile(DoxygenSettingsStruct,Core::IEditor*)), - dox, SLOT(documentFile(DoxygenSettingsStruct,Core::IEditor*))); + connect(this, SIGNAL(doxyDocumentEntity(DoxygenSettingsStruct, Core::IEditor*)), + dox, SLOT(documentEntity(DoxygenSettingsStruct, Core::IEditor*))); + connect(this, SIGNAL(doxyDocumentFile(DoxygenSettingsStruct, Core::IEditor*)), + dox, SLOT(documentFile(DoxygenSettingsStruct, Core::IEditor*))); connect(this, SIGNAL(doxyDocumentCurrentProject(DoxygenSettingsStruct)), - dox, SLOT(documentCurrentProject(DoxygenSettingsStruct))); + dox, SLOT(documentCurrentProject(DoxygenSettingsStruct))); // Process connection for Doxygen m_process = new QProcess(); - connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(processExited(int,QProcess::ExitStatus))); + connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(processExited(int, QProcess::ExitStatus))); connect(m_process, SIGNAL(readyRead()), - this, SLOT(readProcessOutput())); + this, SLOT(readProcessOutput())); return true; } @@ -210,17 +210,17 @@ ExtensionSystem::IPlugin::ShutdownFlag DoxygenPlugin::aboutToShutdown() void DoxygenPlugin::documentEntity() { - Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); + Core::IEditor* editor = Core::EditorManager::instance()->currentEditor(); emit doxyDocumentEntity(settings(), editor); } void DoxygenPlugin::documentFile() { if (QMessageBox::question((QWidget*)this->parent(), - "Doxygen", "Document current File?", - QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) - { - Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); + "Doxygen", "Document current File?", + QMessageBox::Yes, QMessageBox::No) + == QMessageBox::Yes) { + Core::IEditor* editor = Core::EditorManager::instance()->currentEditor(); emit doxyDocumentFile(settings(), editor); } } @@ -240,17 +240,17 @@ bool DoxygenPlugin::buildDocumentation() // TODO: refactor // TODO, allow configuration of the command // the default here will just run doxygen at the project root - ProjectExplorer::Project *p = ProjectExplorer::ProjectTree::currentProject(); + ProjectExplorer::Project* p = ProjectExplorer::ProjectTree::currentProject(); if (!p) { QMessageBox::warning((QWidget*)parent(), - tr("Doxygen"), - tr("You don't have any current project."), - QMessageBox::Close, QMessageBox::NoButton); + tr("Doxygen"), + tr("You don't have any current project."), + QMessageBox::Close, QMessageBox::NoButton); return false; } QString projectRoot = Doxygen::getProjectRoot(); - if(!projectRoot.size()) + if (!projectRoot.size()) return false; QString doxyFile = projectRoot; @@ -260,8 +260,7 @@ bool DoxygenPlugin::buildDocumentation() // TODO: refactor // create default Doxyfile if it doesn't exist QFileInfo doxyFileInfo(doxyFile); - if(!doxyFileInfo.exists()) - { + if (!doxyFileInfo.exists()) { args << "-g" << doxyFile; runDoxygen(args, projectRoot); return true; @@ -275,12 +274,12 @@ void DoxygenPlugin::doxyfileWizard() // TODO: refactor { // prevent a crash if user launches this command with no project opened // You don't need to have an editor open for that. - ProjectExplorer::Project *p = ProjectExplorer::ProjectTree::currentProject(); + ProjectExplorer::Project* p = ProjectExplorer::ProjectTree::currentProject(); if (!p) { QMessageBox::warning((QWidget*)parent(), - tr("Doxygen"), - tr("You don't have any current project."), - QMessageBox::Close, QMessageBox::NoButton); + tr("Doxygen"), + tr("You don't have any current project."), + QMessageBox::Close, QMessageBox::NoButton); return; } @@ -290,18 +289,16 @@ void DoxygenPlugin::doxyfileWizard() // TODO: refactor bool ret = QProcess::startDetached(settings().doxywizardCommand, arglist, projectRoot); - if(!ret) - { + if (!ret) { const QString outputText = tr("Failed to launch %1\n").arg(executable); externalString(outputText); } } -void DoxygenPlugin::runDoxygen(const QStringList &arguments, QString workingDirectory) +void DoxygenPlugin::runDoxygen(const QStringList& arguments, QString workingDirectory) { const QString executable = settings().doxygenCommand; - if(executable.isEmpty()) - { + if (executable.isEmpty()) { externalString(tr("No doxygen executable specified")); return; } @@ -333,8 +330,7 @@ void DoxygenPlugin::processExited(int returnCode, QProcess::ExitStatus exitStatu response.error = true; response.stdErr = QLatin1String(m_process->readAllStandardError()); response.stdOut = QLatin1String(m_process->readAllStandardOutput()); - switch (exitStatus) - { + switch (exitStatus) { case QProcess::NormalExit: response.error = false; break; @@ -344,8 +340,8 @@ void DoxygenPlugin::processExited(int returnCode, QProcess::ExitStatus exitStatu } if (response.error) externalString(response.message); - else externalString(tr("Doxygen ran successfully")); - + else + externalString(tr("Doxygen ran successfully")); } void DoxygenPlugin::readProcessOutput() diff --git a/doxygensettings.cpp b/doxygensettings.cpp index 48fc321..ba9f170 100644 --- a/doxygensettings.cpp +++ b/doxygensettings.cpp @@ -21,63 +21,61 @@ #include "doxygensettings.h" #include "doxygen.h" -#include "doxygenplugin.h" #include "doxygenconstants.h" +#include "doxygenplugin.h" +#include +#include #include -#include #include -#include -#include +#include namespace DoxyPlugin { namespace Internal { -DoxygenSettings::DoxygenSettings() : - m_widget(0) -{ - if(QSettings *settings = Core::ICore::instance()->settings()) - m_settings.fromSettings(settings); - setId("A.General"); - setDisplayName(tr("Doxygen")); - setCategory(Core::Id::fromString(QString(Constants::DOXYGEN_SETTINGS_CATEGORY))); - setDisplayCategory("Doxygen"); - setCategoryIcon(Utils::Icon(":/doxygen.png")); -} - -QWidget* DoxygenSettings::widget() -{ - if (! m_widget) { - m_widget = new DoxygenSettingsWidget; - m_widget->setSettings(settings()); + DoxygenSettings::DoxygenSettings() + : m_widget(0) + { + if (QSettings* settings = Core::ICore::instance()->settings()) + m_settings.fromSettings(settings); + setId("A.General"); + setDisplayName(tr("Doxygen")); + setCategory(Core::Id::fromString(QString(Constants::DOXYGEN_SETTINGS_CATEGORY))); + setDisplayCategory("Doxygen"); + setCategoryIcon(Utils::Icon(":/doxygen.png")); } - return m_widget; -} -void DoxygenSettings::apply() -{ - if (!m_widget) - return; - setSettings(m_widget->settings()); -} + QWidget* DoxygenSettings::widget() + { + if (!m_widget) { + m_widget = new DoxygenSettingsWidget; + m_widget->setSettings(settings()); + } + return m_widget; + } -void DoxygenSettings::finish() -{ -} + void DoxygenSettings::apply() + { + if (!m_widget) + return; + setSettings(m_widget->settings()); + } -DoxygenSettingsStruct DoxygenSettings::settings() const -{ - return m_settings; -} + void DoxygenSettings::finish() + { + } -void DoxygenSettings::setSettings(const DoxygenSettingsStruct &s) -{ - if (s != m_settings) + DoxygenSettingsStruct DoxygenSettings::settings() const { - m_settings = s; - if(QSettings *settings = Core::ICore::instance()->settings()) - m_settings.toSettings(settings); + return m_settings; } -} + void DoxygenSettings::setSettings(const DoxygenSettingsStruct& s) + { + if (s != m_settings) { + m_settings = s; + if (QSettings* settings = Core::ICore::instance()->settings()) + m_settings.toSettings(settings); + } + } } } diff --git a/doxygensettingsstruct.cpp b/doxygensettingsstruct.cpp index 1e50bb0..32d1a93 100644 --- a/doxygensettingsstruct.cpp +++ b/doxygensettingsstruct.cpp @@ -19,33 +19,33 @@ ** along with Doxygen Plugin. If not, see . **/ +#include "doxygensettingsstruct.h" #include #include -#include "doxygensettingsstruct.h" using namespace DoxyPlugin; using namespace DoxyPlugin::Internal; -static const char *groupC = "Doxygen"; -static const char *commandKeyC = "Command"; -static const char *doxyfilePathKeyC = "DoxyConfigFile"; -static const char *wizardcommandKeyC = "Wizard"; -static const char *styleKeyC = "Style"; -static const char *fcommentKeyC = "Files2Comment"; -static const char *printBriefKeyC = "PrintBrief"; -static const char *printShortVarDocKeyC = "PrintShortVarDoc"; -static const char *verbosePrintingKeyC = "VerbosePrinting"; -static const char *automaticAddReturnType = "AutomaticAddReturnType"; -static const char *customBeginKeyC = "CustomBegin"; -static const char *customBriefKeyC= "CustomBrief"; -static const char *customEmptyLineKeyC= "CustomEmptyLine"; -static const char *customNewLineKeyC= "CustomNewLine"; -static const char *customEndingKeyC= "CustomEnding"; -static const char *customShortDocKeyC= "CustomShortDoc"; -static const char *customShortDocEndKeyC= "CustomShortDocEnd"; -static const char *fileCommentEnabledKeyC = "FileComments"; -static const char *fileCommentHeadersKeyC = "FileCommentHeaders"; -static const char *fileCommentImplKeyC = "FileCommentImplementations"; -static const char *fileCommentKeyC = "FileComment"; +static const char* groupC = "Doxygen"; +static const char* commandKeyC = "Command"; +static const char* doxyfilePathKeyC = "DoxyConfigFile"; +static const char* wizardcommandKeyC = "Wizard"; +static const char* styleKeyC = "Style"; +static const char* fcommentKeyC = "Files2Comment"; +static const char* printBriefKeyC = "PrintBrief"; +static const char* printShortVarDocKeyC = "PrintShortVarDoc"; +static const char* verbosePrintingKeyC = "VerbosePrinting"; +static const char* automaticAddReturnType = "AutomaticAddReturnType"; +static const char* customBeginKeyC = "CustomBegin"; +static const char* customBriefKeyC = "CustomBrief"; +static const char* customEmptyLineKeyC = "CustomEmptyLine"; +static const char* customNewLineKeyC = "CustomNewLine"; +static const char* customEndingKeyC = "CustomEnding"; +static const char* customShortDocKeyC = "CustomShortDoc"; +static const char* customShortDocEndKeyC = "CustomShortDocEnd"; +static const char* fileCommentEnabledKeyC = "FileComments"; +static const char* fileCommentHeadersKeyC = "FileCommentHeaders"; +static const char* fileCommentImplKeyC = "FileCommentImplementations"; +static const char* fileCommentKeyC = "FileComment"; static QString defaultCommand() { @@ -70,22 +70,21 @@ static QString defaultDoxyFile() return QLatin1String("Doxyfile"); } - -DoxygenSettingsStruct::DoxygenSettingsStruct() : - doxyfileFileName(defaultDoxyFile()), - doxygenCommand(defaultCommand()), - doxywizardCommand(defaultWizardCommand()), - style(qtDoc), - fcomment(headers), - printBrief(true), - shortVarDoc(true), - verbosePrinting(false), - automaticReturnType(true) +DoxygenSettingsStruct::DoxygenSettingsStruct() + : doxyfileFileName(defaultDoxyFile()) + , doxygenCommand(defaultCommand()) + , doxywizardCommand(defaultWizardCommand()) + , style(qtDoc) + , fcomment(headers) + , printBrief(true) + , shortVarDoc(true) + , verbosePrinting(false) + , automaticReturnType(true) { qRegisterMetaType("DoxygenSettingsStruct"); } -void DoxygenSettingsStruct::fromSettings(QSettings *settings) +void DoxygenSettingsStruct::fromSettings(QSettings* settings) { settings->beginGroup(QLatin1String(groupC)); doxygenCommand = settings->value(QLatin1String(commandKeyC), defaultCommand()).toString(); @@ -115,11 +114,11 @@ void DoxygenSettingsStruct::fromSettings(QSettings *settings) setDoxygenCommentStyle(style); } -void DoxygenSettingsStruct::toSettings(QSettings *settings) +void DoxygenSettingsStruct::toSettings(QSettings* settings) { settings->beginGroup(QLatin1String(groupC)); settings->setValue(QLatin1String(commandKeyC), doxygenCommand); - settings->setValue(QLatin1String(doxyfilePathKeyC),doxyfileFileName); + settings->setValue(QLatin1String(doxyfilePathKeyC), doxyfileFileName); settings->setValue(QLatin1String(wizardcommandKeyC), doxywizardCommand); settings->setValue(QLatin1String(styleKeyC), style); settings->setValue(QLatin1String(fcommentKeyC), fcomment); @@ -127,7 +126,7 @@ void DoxygenSettingsStruct::toSettings(QSettings *settings) settings->setValue(QLatin1String(printShortVarDocKeyC), shortVarDoc); settings->setValue(QLatin1String(verbosePrintingKeyC), verbosePrinting); settings->setValue(QLatin1String(automaticAddReturnType), automaticReturnType); - settings->setValue(QLatin1String(customBeginKeyC),customBegin ); + settings->setValue(QLatin1String(customBeginKeyC), customBegin); settings->setValue(QLatin1String(customBriefKeyC), customBrief); settings->setValue(QLatin1String(customEmptyLineKeyC), customEmptyLine); settings->setValue(QLatin1String(customNewLineKeyC), customNewLine); @@ -144,47 +143,45 @@ void DoxygenSettingsStruct::toSettings(QSettings *settings) setDoxygenCommentStyle(style); } -bool DoxygenSettingsStruct::equals(const DoxygenSettingsStruct &s) const +bool DoxygenSettingsStruct::equals(const DoxygenSettingsStruct& s) const { - return - doxygenCommand == s.doxygenCommand - && doxywizardCommand == s.doxywizardCommand - && doxyfileFileName == s.doxyfileFileName - && style == s.style - && fcomment == s.fcomment - && printBrief == s.printBrief - && shortVarDoc == s.shortVarDoc - && verbosePrinting == s.verbosePrinting - && automaticReturnType == s.automaticReturnType - && customBegin == s.customBegin - && customBrief == s.customBrief - && customEmptyLine == s.customEmptyLine - && customNewLine == s.customNewLine - && customEnding == s.customEnding - && customShortDoc == s.customShortDoc - && customShortDocEnd == s.customShortDocEnd - && fileComment == s.fileComment - && fileCommentHeaders == s.fileCommentHeaders - && fileCommentImpl == s.fileCommentImpl - && fileCommentsEnabled == s.fileCommentsEnabled; + return doxygenCommand == s.doxygenCommand + && doxywizardCommand == s.doxywizardCommand + && doxyfileFileName == s.doxyfileFileName + && style == s.style + && fcomment == s.fcomment + && printBrief == s.printBrief + && shortVarDoc == s.shortVarDoc + && verbosePrinting == s.verbosePrinting + && automaticReturnType == s.automaticReturnType + && customBegin == s.customBegin + && customBrief == s.customBrief + && customEmptyLine == s.customEmptyLine + && customNewLine == s.customNewLine + && customEnding == s.customEnding + && customShortDoc == s.customShortDoc + && customShortDocEnd == s.customShortDocEnd + && fileComment == s.fileComment + && fileCommentHeaders == s.fileCommentHeaders + && fileCommentImpl == s.fileCommentImpl + && fileCommentsEnabled == s.fileCommentsEnabled; } -QStringList DoxygenSettingsStruct::addOptions(const QStringList &args) const +QStringList DoxygenSettingsStruct::addOptions(const QStringList& args) const { // TODO, look at possible doxygen args in the manual and act here... return args; } -QString DoxygenSettingsStruct::formatArguments(const QStringList &args) +QString DoxygenSettingsStruct::formatArguments(const QStringList& args) { // TODO find out if it can really be useful or get rid of it QString rc; QTextStream str(&rc); const int size = args.size(); - for (int i = 0; i < size; i++) - { - const QString &arg = args.at(i); + for (int i = 0; i < size; i++) { + const QString& arg = args.at(i); if (i) str << ' '; str << arg; @@ -195,42 +192,37 @@ QString DoxygenSettingsStruct::formatArguments(const QStringList &args) void DoxygenSettingsStruct::setDoxygenCommentStyle(DoxygenStyle s) { - switch(s) { - case javaDoc: - { - DoxyComment.doxBegin = "/**\n"; - DoxyComment.doxBrief = " * @brief \n"; - DoxyComment.doxEmptyLine = " *\n"; - DoxyComment.doxNewLine = " * @"; - DoxyComment.doxEnding = " */\n"; - DoxyComment.doxShortVarDoc = " /**< "; - DoxyComment.doxShortVarDocEnd = " */"; - break; - - + switch (s) { + case javaDoc: { + DoxyComment.doxBegin = "/**\n"; + DoxyComment.doxBrief = " * @brief \n"; + DoxyComment.doxEmptyLine = " *\n"; + DoxyComment.doxNewLine = " * @"; + DoxyComment.doxEnding = " */\n"; + DoxyComment.doxShortVarDoc = " /**< "; + DoxyComment.doxShortVarDocEnd = " */"; + break; } - case customDoc : - { - DoxyComment.doxBegin = customBegin; - DoxyComment.doxBrief = customBrief; - DoxyComment.doxEmptyLine = customEmptyLine; - DoxyComment.doxNewLine = customNewLine; - DoxyComment.doxEnding = customEnding; - DoxyComment.doxShortVarDoc = customShortDoc; - DoxyComment.doxShortVarDocEnd = customShortDocEnd; - break; + case customDoc: { + DoxyComment.doxBegin = customBegin; + DoxyComment.doxBrief = customBrief; + DoxyComment.doxEmptyLine = customEmptyLine; + DoxyComment.doxNewLine = customNewLine; + DoxyComment.doxEnding = customEnding; + DoxyComment.doxShortVarDoc = customShortDoc; + DoxyComment.doxShortVarDocEnd = customShortDocEnd; + break; } default: //case qtDoc: { - DoxyComment.doxBegin = "/*!\n"; - DoxyComment.doxBrief = " \\brief \n"; - DoxyComment.doxEmptyLine = "\n"; - DoxyComment.doxNewLine = " \\"; - DoxyComment.doxEnding = "*/\n"; - DoxyComment.doxShortVarDoc = " /*!< "; - DoxyComment.doxShortVarDocEnd = " */"; - break; - + DoxyComment.doxBegin = "/*!\n"; + DoxyComment.doxBrief = " \\brief \n"; + DoxyComment.doxEmptyLine = "\n"; + DoxyComment.doxNewLine = " \\"; + DoxyComment.doxEnding = "*/\n"; + DoxyComment.doxShortVarDoc = " /*!< "; + DoxyComment.doxShortVarDocEnd = " */"; + break; } } } diff --git a/doxygensettingswidget.cpp b/doxygensettingswidget.cpp index 9e72a72..30b05e6 100644 --- a/doxygensettingswidget.cpp +++ b/doxygensettingswidget.cpp @@ -22,9 +22,9 @@ #include "doxygensettingswidget.h" #include "ui_doxygensettingswidget.h" -DoxygenSettingsWidget::DoxygenSettingsWidget(QWidget *parent) : - QWidget(parent), - ui(new Ui::DoxygenSettingsWidget) +DoxygenSettingsWidget::DoxygenSettingsWidget(QWidget* parent) + : QWidget(parent) + , ui(new Ui::DoxygenSettingsWidget) { ui->setupUi(this); ui->pathChooser_doxygen->setExpectedKind(Utils::PathChooser::Command); @@ -41,7 +41,7 @@ DoxygenSettingsWidget::~DoxygenSettingsWidget() delete ui; } -void DoxygenSettingsWidget::changeEvent(QEvent *e) +void DoxygenSettingsWidget::changeEvent(QEvent* e) { QWidget::changeEvent(e); switch (e->type()) { @@ -79,7 +79,7 @@ DoxygenSettingsStruct DoxygenSettingsWidget::settings() const return rc; } -void DoxygenSettingsWidget::setSettings(const DoxygenSettingsStruct &s) +void DoxygenSettingsWidget::setSettings(const DoxygenSettingsStruct& s) { ui->pathChooser_doxygen->setPath(s.doxygenCommand); ui->pathChooser_wizard->setPath(s.doxywizardCommand); @@ -115,24 +115,19 @@ void DoxygenSettingsWidget::on_fileComments_clicked(bool checked) { Files2Comment toComment = Files2Comment(ui->fcommentChooser->currentIndex()); ui->fileCommentText->setEnabled(checked); - if(checked == false || toComment == all) - { + if (checked == false || toComment == all) { checked = false; ui->label_filecommentHeaders->setVisible(checked); ui->label_filecommentImpl->setVisible(checked); ui->commentHeaderFiles->setVisible(checked); ui->commentImplementationFiles->setVisible(checked); - } - else if(toComment == headers) - { + } else if (toComment == headers) { ui->label_filecommentHeaders->setVisible(false); ui->label_filecommentImpl->setVisible(true); ui->commentHeaderFiles->setVisible(false); ui->commentImplementationFiles->setVisible(true); - } - else if(toComment == implementations) - { + } else if (toComment == implementations) { ui->label_filecommentHeaders->setVisible(true); ui->label_filecommentImpl->setVisible(false); ui->commentHeaderFiles->setVisible(true);