data: Option to run only C/C++ preprocessor when indexing (issue 297)

* Added as checkbox to indexing start dialog
* Only shown for C/C++ projects
* Files will be marked incomplete
This commit is contained in:
Eberhard Graether
2017-04-18 22:11:20 +02:00
parent 2b24b88745
commit 63087913bd
31 changed files with 373 additions and 231 deletions
+57 -32
View File
@@ -7,6 +7,7 @@
#include <QPushButton>
#include "qt/utility/utilityQt.h"
#include "qt/element/QtHelpButton.h"
#include "qt/element/QtProgressBar.h"
#include "utility/messaging/type/MessageInterruptTasks.h"
#include "utility/ResourcePaths.h"
@@ -22,11 +23,11 @@ QtIndexingDialog::QtIndexingDialog(QWidget* parent)
, m_messageLabel(nullptr)
, m_filePathLabel(nullptr)
, m_errorLabel(nullptr)
, m_checkBox(nullptr)
, m_fullRefreshCheckBox(nullptr)
, m_preprocessorOnlyCheckBox(nullptr)
, m_sizeHint(QSize(450, 450))
, m_callback([](bool, bool){})
, m_callback([](DialogView::IndexingOptions){})
{
// setWindowFlags(Qt::WindowStaysOnTopHint);
setSizeGripStyle(false);
}
@@ -42,7 +43,7 @@ QtIndexingDialog::DialogType QtIndexingDialog::getType() const
void QtIndexingDialog::setupStart(
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
bool forceRefresh, bool needsFullRefresh, std::function<void(bool, bool)> callback)
DialogView::IndexingOptions options, std::function<void(DialogView::IndexingOptions)> callback)
{
QBoxLayout* layout = createLayout();
@@ -59,46 +60,65 @@ void QtIndexingDialog::setupStart(
layout->addStretch();
if (needsFullRefresh)
if (options.fullRefreshVisible)
{
m_fullRefreshCheckBox = new QCheckBox("full refresh", this);
m_fullRefreshCheckBox->setObjectName("message");
connect(m_fullRefreshCheckBox, static_cast<void(QCheckBox::*)(bool)>(&QCheckBox::toggled),
[=](bool checked = false)
{
clearLabel->setVisible(!checked);
indexLabel->setVisible(!checked);
fullLabel->setVisible(checked);
}
);
m_fullRefreshCheckBox->setChecked(!options.fullRefresh);
m_fullRefreshCheckBox->setChecked(options.fullRefresh);
QHBoxLayout* subLayout = new QHBoxLayout();
subLayout->addStretch();
subLayout->addWidget(m_fullRefreshCheckBox);
layout->addLayout(subLayout);
}
else
{
clearLabel->hide();
indexLabel->hide();
}
else
if (options.preprocessorOnlyVisible)
{
m_checkBox = new QCheckBox("full refresh", this);
m_checkBox->setObjectName("message");
m_preprocessorOnlyCheckBox = new QCheckBox("C/C++ preprocessor only", this);
m_preprocessorOnlyCheckBox->setObjectName("message");
m_preprocessorOnlyCheckBox->setChecked(options.preprocessorOnly);
connect(m_checkBox, static_cast<void(QCheckBox::*)(bool)>(&QCheckBox::toggled),
[=](bool checked = false)
{
if (checked)
{
clearLabel->hide();
indexLabel->hide();
fullLabel->show();
}
else
{
clearLabel->show();
indexLabel->show();
fullLabel->hide();
}
}
);
QtHelpButton* button = new QtHelpButton(
"Run only the C/C++ preprocessor on the files. This will quickly show include errors and help fix problems "
"in the project setup faster.\n\nThe files will not be indexed and show up as incomplete.");
button->setColor(Qt::white);
m_checkBox->setChecked(!forceRefresh);
m_checkBox->setChecked(forceRefresh);
QHBoxLayout* subLayout = new QHBoxLayout();
subLayout->addStretch();
subLayout->addWidget(m_preprocessorOnlyCheckBox);
subLayout->addSpacing(10);
subLayout->addWidget(button);
layout->addWidget(m_checkBox, 0, Qt::AlignRight);
layout->addSpacing(30);
layout->addLayout(subLayout);
}
if (m_fullRefreshCheckBox || m_preprocessorOnlyCheckBox)
{
layout->addSpacing(20);
}
addButtons(layout);
updateNextButton("Start");
updateCloseButton("Cancel");
m_sizeHint = QSize(350, 250);
m_sizeHint = QSize(350, 270);
m_callback = callback;
finishSetup();
@@ -277,7 +297,11 @@ void QtIndexingDialog::handleNext()
{
if (m_type == DIALOG_MESSAGE)
{
m_callback(true, !m_checkBox || m_checkBox->isChecked());
DialogView::IndexingOptions options;
options.startIndexing = true;
options.fullRefresh = m_fullRefreshCheckBox && m_fullRefreshCheckBox->isChecked();
options.preprocessorOnly = m_preprocessorOnlyCheckBox && m_preprocessorOnlyCheckBox->isChecked();
m_callback(options);
}
QtWindow::handleNext();
@@ -287,7 +311,8 @@ void QtIndexingDialog::handleClose()
{
if (m_type == DIALOG_MESSAGE)
{
m_callback(false, false);
DialogView::IndexingOptions options;
m_callback(options);
}
if (m_type == DIALOG_INDEXING)
+7 -3
View File
@@ -3,6 +3,7 @@
#include <functional>
#include "component/view/DialogView.h"
#include "qt/window/QtWindow.h"
class QCheckBox;
@@ -29,7 +30,7 @@ public:
DialogType getType() const;
void setupStart(size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
bool forceRefresh, bool needsFullRefresh, std::function<void(bool, bool)> callback);
DialogView::IndexingOptions options, std::function<void(DialogView::IndexingOptions)> callback);
void setupIndexing();
void setupReport(
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time);
@@ -77,11 +78,14 @@ private:
QLabel* m_messageLabel;
QLabel* m_filePathLabel;
QPushButton* m_errorLabel;
QCheckBox* m_checkBox;
// start indexing
QCheckBox* m_fullRefreshCheckBox;
QCheckBox* m_preprocessorOnlyCheckBox;
QSize m_sizeHint;
std::function<void(bool, bool)> m_callback;
std::function<void(DialogView::IndexingOptions)> m_callback;
QString m_sourcePath;
};
@@ -2,41 +2,9 @@
#include <thread>
#include <QMessageBox>
#include "qt/window/QtTextEditDialog.h"
#include "utility/ResourcePaths.h"
#include "utility/utilityString.h"
QtHelpButton::QtHelpButton(const QString& helpText, QWidget* parent)
: QtIconButton(
(ResourcePaths::getGuiPath() + "window/help.png").c_str(),
(ResourcePaths::getGuiPath() + "window/help_hover.png").c_str(),
parent)
, m_helpText(helpText)
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
setMouseTracking(true);
setToolTip("help");
leaveEvent(nullptr);
connect(this, SIGNAL(clicked()), this, SLOT(handleHelpPress()));
}
void QtHelpButton::handleHelpPress()
{
QMessageBox msgBox;
msgBox.setText("Help");
msgBox.setInformativeText(m_helpText);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
QtProjectWizzardContent::QtProjectWizzardContent(QtProjectWizzardWindow* window)
: QWidget(window)
, m_window(window)
@@ -6,29 +6,13 @@
#include <QToolButton>
#include <QWidget>
#include "qt/element/QtIconButton.h"
#include "qt/element/QtHelpButton.h"
#include "qt/utility/QtThreadedFunctor.h"
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
#include "settings/ProjectSettings.h"
class QtTextEditDialog;
class QtHelpButton
: public QtIconButton
{
Q_OBJECT
public:
QtHelpButton(const QString& helpText, QWidget* parent = nullptr);
private slots:
void handleHelpPress();
private:
QString m_helpText;
};
class QtProjectWizzardContent
: public QWidget
{