Utils: Modernize

modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
modernize-use-default-member-init
modernize-use-equals-default

Change-Id: I8d44d9405011a1878353baf9325f7af90b89db02
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Alessandro Portale
2018-07-19 16:39:41 +02:00
parent 1d894c0f7a
commit e38410b76c
58 changed files with 274 additions and 315 deletions

View File

@@ -33,8 +33,7 @@ using namespace Utils;
AnnotatedItemDelegate::AnnotatedItemDelegate(QObject *parent) : QStyledItemDelegate(parent)
{}
AnnotatedItemDelegate::~AnnotatedItemDelegate()
{}
AnnotatedItemDelegate::~AnnotatedItemDelegate() = default;
void AnnotatedItemDelegate::setAnnotationRole(int role)
{
@@ -110,5 +109,5 @@ QSize AnnotatedItemDelegate::sizeHint(const QStyleOptionViewItem &option,
if (!annotation.isEmpty())
opt.text += m_delimiter + annotation;
return QApplication::style()->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), 0);
return QApplication::style()->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), nullptr);
}

View File

@@ -50,19 +50,19 @@ class BaseTreeViewPrivate : public QObject
{
public:
explicit BaseTreeViewPrivate(BaseTreeView *parent)
: q(parent), m_settings(0), m_expectUserChanges(false), m_progressIndicator(0)
: q(parent)
{
m_settingsTimer.setSingleShot(true);
connect(&m_settingsTimer, &QTimer::timeout,
this, &BaseTreeViewPrivate::doSaveState);
}
bool eventFilter(QObject *, QEvent *event)
bool eventFilter(QObject *, QEvent *event) override
{
if (event->type() == QEvent::MouseMove) {
// At this time we don't know which section will get which size.
// But we know that a resizedSection() will be emitted later.
QMouseEvent *me = static_cast<QMouseEvent *>(event);
const auto *me = static_cast<QMouseEvent *>(event);
if (me->buttons() & Qt::LeftButton)
m_expectUserChanges = true;
}
@@ -219,11 +219,11 @@ public:
public:
BaseTreeView *q;
QMap<int, int> m_userHandled; // column -> width, "not present" means "automatic"
QSettings *m_settings;
QSettings *m_settings = nullptr;
QTimer m_settingsTimer;
QString m_settingsKey;
bool m_expectUserChanges;
ProgressIndicator *m_progressIndicator;
bool m_expectUserChanges = false;
ProgressIndicator *m_progressIndicator = nullptr;
};
class BaseTreeViewDelegate : public QItemDelegate
@@ -232,7 +232,7 @@ public:
BaseTreeViewDelegate(QObject *parent): QItemDelegate(parent) {}
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const
const QModelIndex &index) const override
{
Q_UNUSED(option);
QLabel *label = new QLabel(parent);
@@ -283,7 +283,7 @@ BaseTreeView::~BaseTreeView()
void BaseTreeView::setModel(QAbstractItemModel *m)
{
if (BaseTreeModel *oldModel = qobject_cast<BaseTreeModel *>(model())) {
if (auto oldModel = qobject_cast<BaseTreeModel *>(model())) {
disconnect(oldModel, &BaseTreeModel::requestExpansion, this, &BaseTreeView::expand);
disconnect(oldModel, &BaseTreeModel::requestCollapse, this, &BaseTreeView::collapse);
}
@@ -291,7 +291,7 @@ void BaseTreeView::setModel(QAbstractItemModel *m)
TreeView::setModel(m);
if (m) {
if (BaseTreeModel *newModel = qobject_cast<BaseTreeModel *>(m)) {
if (auto newModel = qobject_cast<BaseTreeModel *>(m)) {
connect(newModel, &BaseTreeModel::requestExpansion, this, &BaseTreeView::expand);
connect(newModel, &BaseTreeModel::requestCollapse, this, &BaseTreeView::collapse);
}

View File

@@ -116,8 +116,8 @@ QList<ChangeSet::EditOp> ChangeSet::operationList() const
void ChangeSet::clear()
{
m_string = 0;
m_cursor = 0;
m_string = nullptr;
m_cursor = nullptr;
m_operationList.clear();
m_error = false;
}
@@ -334,14 +334,14 @@ void ChangeSet::apply(QString *s)
{
m_string = s;
apply_helper();
m_string = 0;
m_string = nullptr;
}
void ChangeSet::apply(QTextCursor *textCursor)
{
m_cursor = textCursor;
apply_helper();
m_cursor = 0;
m_cursor = nullptr;
}
QString ChangeSet::textAt(int pos, int length)

View File

@@ -52,7 +52,6 @@ class CheckableMessageBoxPrivate
{
public:
CheckableMessageBoxPrivate(QDialog *q)
: clickedButton(0)
{
QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
@@ -63,7 +62,7 @@ public:
pixmapLabel->setSizePolicy(sizePolicy);
pixmapLabel->setVisible(false);
QSpacerItem *pixmapSpacer =
auto pixmapSpacer =
new QSpacerItem(0, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
messageLabel = new QLabel(q);
@@ -72,9 +71,9 @@ public:
messageLabel->setOpenExternalLinks(true);
messageLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse);
QSpacerItem *checkBoxRightSpacer =
auto checkBoxRightSpacer =
new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
QSpacerItem *buttonSpacer =
auto buttonSpacer =
new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::Minimum);
checkBox = new QCheckBox(q);
@@ -84,30 +83,30 @@ public:
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
QVBoxLayout *verticalLayout = new QVBoxLayout();
auto verticalLayout = new QVBoxLayout();
verticalLayout->addWidget(pixmapLabel);
verticalLayout->addItem(pixmapSpacer);
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
auto horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->addLayout(verticalLayout);
horizontalLayout_2->addWidget(messageLabel);
QHBoxLayout *horizontalLayout = new QHBoxLayout();
auto horizontalLayout = new QHBoxLayout();
horizontalLayout->addWidget(checkBox);
horizontalLayout->addItem(checkBoxRightSpacer);
QVBoxLayout *verticalLayout_2 = new QVBoxLayout(q);
auto verticalLayout_2 = new QVBoxLayout(q);
verticalLayout_2->addLayout(horizontalLayout_2);
verticalLayout_2->addLayout(horizontalLayout);
verticalLayout_2->addItem(buttonSpacer);
verticalLayout_2->addWidget(buttonBox);
}
QLabel *pixmapLabel;
QLabel *messageLabel;
QCheckBox *checkBox;
QDialogButtonBox *buttonBox;
QAbstractButton *clickedButton;
QLabel *pixmapLabel = nullptr;
QLabel *messageLabel = nullptr;
QCheckBox *checkBox = nullptr;
QDialogButtonBox *buttonBox = nullptr;
QAbstractButton *clickedButton = nullptr;
};
CheckableMessageBox::CheckableMessageBox(QWidget *parent) :
@@ -215,7 +214,7 @@ QPushButton *CheckableMessageBox::addButton(const QString &text, QDialogButtonBo
QDialogButtonBox::StandardButton CheckableMessageBox::defaultButton() const
{
foreach (QAbstractButton *b, d->buttonBox->buttons())
if (QPushButton *pb = qobject_cast<QPushButton *>(b))
if (auto *pb = qobject_cast<QPushButton *>(b))
if (pb->isDefault())
return d->buttonBox->standardButton(pb);
return QDialogButtonBox::NoButton;

View File

@@ -45,17 +45,14 @@ struct ClassNameValidatingLineEditPrivate {
QRegExp m_nameRegexp;
QString m_namespaceDelimiter;
bool m_namespacesEnabled;
bool m_lowerCaseFileName;
bool m_forceFirstCapitalLetter;
bool m_namespacesEnabled = false;
bool m_lowerCaseFileName = true;
bool m_forceFirstCapitalLetter = false;
};
// Match something like "Namespace1::Namespace2::ClassName".
ClassNameValidatingLineEditPrivate:: ClassNameValidatingLineEditPrivate() :
m_namespaceDelimiter(QLatin1String("::")),
m_namespacesEnabled(false),
m_lowerCaseFileName(true),
m_forceFirstCapitalLetter(false)
m_namespaceDelimiter(QLatin1String("::"))
{
}

View File

@@ -43,7 +43,7 @@ bool CompletingLineEdit::event(QEvent *e)
if (e->type() == QEvent::ShortcutOverride) {
if (QCompleter *comp = completer()) {
if (comp->popup() && comp->popup()->isVisible()) {
QKeyEvent *ke = static_cast<QKeyEvent *>(e);
auto ke = static_cast<QKeyEvent *>(e);
if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ke->accept();
return true;

View File

@@ -55,17 +55,15 @@ public:
bool acceptsCompletionPrefix(const QString &prefix) const;
QCompleter *m_completer;
int m_completionLengthThreshold;
QCompleter *m_completer = nullptr;
int m_completionLengthThreshold = 3;
private:
CompletingTextEdit *m_backPointer;
};
CompletingTextEditPrivate::CompletingTextEditPrivate(CompletingTextEdit *textEdit)
: m_completer(0),
m_completionLengthThreshold(3),
m_backPointer(textEdit)
: m_backPointer(textEdit)
{
}
@@ -107,7 +105,7 @@ CompletingTextEdit::~CompletingTextEdit()
void CompletingTextEdit::setCompleter(QCompleter *c)
{
if (completer())
disconnect(completer(), 0, this, 0);
disconnect(completer(), nullptr, this, nullptr);
d->m_completer = c;
@@ -153,12 +151,12 @@ void CompletingTextEdit::keyPressEvent(QKeyEvent *e)
}
const bool isShortcut = ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_E); // CTRL+E
if (completer() == 0 || !isShortcut) // do not process the shortcut when we have a completer
if (completer() == nullptr || !isShortcut) // do not process the shortcut when we have a completer
QTextEdit::keyPressEvent(e);
const bool ctrlOrShift = e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier);
const QString text = e->text();
if (completer() == 0 || (ctrlOrShift && text.isEmpty()))
if (completer() == nullptr || (ctrlOrShift && text.isEmpty()))
return;
const bool hasModifier = (e->modifiers() != Qt::NoModifier) && !ctrlOrShift;
@@ -183,7 +181,7 @@ void CompletingTextEdit::keyPressEvent(QKeyEvent *e)
void CompletingTextEdit::focusInEvent(QFocusEvent *e)
{
if (completer() != 0)
if (completer() != nullptr)
completer()->setWidget(this);
QTextEdit::focusInEvent(e);
}
@@ -193,7 +191,7 @@ bool CompletingTextEdit::event(QEvent *e)
// workaround for QTCREATORBUG-9453
if (e->type() == QEvent::ShortcutOverride && completer()
&& completer()->popup() && completer()->popup()->isVisible()) {
QKeyEvent *ke = static_cast<QKeyEvent *>(e);
auto ke = static_cast<QKeyEvent *>(e);
if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ke->accept();
return true;

View File

@@ -39,14 +39,14 @@ namespace Utils {
ConsoleProcessPrivate::ConsoleProcessPrivate() :
m_mode(ConsoleProcess::Run),
m_appPid(0),
m_stubSocket(0),
m_tempFile(0),
m_stubSocket(nullptr),
m_tempFile(nullptr),
m_error(QProcess::UnknownError),
m_appMainThreadId(0),
m_pid(0),
m_pid(nullptr),
m_hInferior(NULL),
inferiorFinishedNotifier(0),
processFinishedNotifier(0)
inferiorFinishedNotifier(nullptr),
processFinishedNotifier(nullptr)
{
}
@@ -95,7 +95,7 @@ bool ConsoleProcess::start(const QString &program, const QString &args)
stubServerShutdown();
emitError(QProcess::FailedToStart, msgCannotCreateTempFile(d->m_tempFile->errorString()));
delete d->m_tempFile;
d->m_tempFile = 0;
d->m_tempFile = nullptr;
return false;
}
QTextStream out(d->m_tempFile);
@@ -109,7 +109,7 @@ bool ConsoleProcess::start(const QString &program, const QString &args)
stubServerShutdown();
emitError(QProcess::FailedToStart, msgCannotWriteTempFile());
delete d->m_tempFile;
d->m_tempFile = 0;
d->m_tempFile = nullptr;
return false;
}
}
@@ -143,9 +143,9 @@ bool ConsoleProcess::start(const QString &program, const QString &args)
if (!success) {
delete d->m_pid;
d->m_pid = 0;
d->m_pid = nullptr;
delete d->m_tempFile;
d->m_tempFile = 0;
d->m_tempFile = nullptr;
stubServerShutdown();
emitError(QProcess::FailedToStart, tr("The process \"%1\" could not be started: %2").arg(cmdLine, winErrorMessage(GetLastError())));
return false;
@@ -183,7 +183,7 @@ void ConsoleProcess::stop()
bool ConsoleProcess::isRunning() const
{
return d->m_pid != 0;
return d->m_pid != nullptr;
}
QString ConsoleProcess::stubServerListen()
@@ -198,7 +198,7 @@ QString ConsoleProcess::stubServerListen()
void ConsoleProcess::stubServerShutdown()
{
delete d->m_stubSocket;
d->m_stubSocket = 0;
d->m_stubSocket = nullptr;
if (d->m_stubServer.isListening())
d->m_stubServer.close();
}
@@ -224,7 +224,7 @@ void ConsoleProcess::readStubOutput()
} else if (out.startsWith("pid ")) {
// Will not need it any more
delete d->m_tempFile;
d->m_tempFile = 0;
d->m_tempFile = nullptr;
d->m_appPid = out.mid(4).toLongLong();
d->m_hInferior = OpenProcess(
@@ -251,7 +251,7 @@ void ConsoleProcess::readStubOutput()
void ConsoleProcess::cleanupInferior()
{
delete d->inferiorFinishedNotifier;
d->inferiorFinishedNotifier = 0;
d->inferiorFinishedNotifier = nullptr;
CloseHandle(d->m_hInferior);
d->m_hInferior = NULL;
d->m_appPid = 0;
@@ -274,13 +274,13 @@ void ConsoleProcess::cleanupStub()
{
stubServerShutdown();
delete d->processFinishedNotifier;
d->processFinishedNotifier = 0;
d->processFinishedNotifier = nullptr;
CloseHandle(d->m_pid->hThread);
CloseHandle(d->m_pid->hProcess);
delete d->m_pid;
d->m_pid = 0;
d->m_pid = nullptr;
delete d->m_tempFile;
d->m_tempFile = 0;
d->m_tempFile = nullptr;
}
void ConsoleProcess::stubExited()

View File

@@ -100,7 +100,7 @@ DetailsWidgetPrivate::DetailsWidgetPrivate(QWidget *parent) :
m_hovered(false),
m_useCheckBox(false)
{
QHBoxLayout *summaryLayout = new QHBoxLayout;
auto summaryLayout = new QHBoxLayout;
summaryLayout->setContentsMargins(MARGIN, MARGIN, MARGIN, MARGIN);
summaryLayout->setSpacing(0);
@@ -177,7 +177,7 @@ void DetailsWidgetPrivate::updateControls()
for (QWidget *w = q; w; w = w->parentWidget()) {
if (w->layout())
w->layout()->activate();
if (QScrollArea *area = qobject_cast<QScrollArea*>(w)) {
if (auto area = qobject_cast<QScrollArea*>(w)) {
QEvent e(QEvent::LayoutRequest);
QCoreApplication::sendEvent(area, &e);
}
@@ -249,7 +249,7 @@ void DetailsWidget::setSummaryFontBold(bool b)
void DetailsWidget::setIcon(const QIcon &icon)
{
int iconSize = style()->pixelMetric(QStyle::PM_ButtonIconSize, 0, this);
int iconSize = style()->pixelMetric(QStyle::PM_ButtonIconSize, nullptr, this);
d->m_summaryLabelIcon->setFixedWidth(icon.isNull() ? 0 : iconSize);
d->m_summaryLabelIcon->setPixmap(icon.pixmap(iconSize, iconSize));
d->m_summaryCheckBox->setIcon(icon);
@@ -347,10 +347,10 @@ QWidget *DetailsWidget::widget() const
QWidget *DetailsWidget::takeWidget()
{
QWidget *widget = d->m_widget;
d->m_widget = 0;
d->m_widget = nullptr;
d->m_grid->removeWidget(widget);
if (widget)
widget->setParent(0);
widget->setParent(nullptr);
return widget;
}

View File

@@ -39,10 +39,10 @@
namespace Utils {
static bool isFileDrop(const QMimeData *d, QList<DropSupport::FileSpec> *files = 0)
static bool isFileDrop(const QMimeData *d, QList<DropSupport::FileSpec> *files = nullptr)
{
// internal drop
if (const DropMimeData *internalData = qobject_cast<const DropMimeData *>(d)) {
if (const auto internalData = qobject_cast<const DropMimeData *>(d)) {
if (files)
*files = internalData->files();
return !internalData->files().isEmpty();
@@ -99,7 +99,7 @@ bool DropSupport::isFileDrop(QDropEvent *event) const
bool DropSupport::isValueDrop(QDropEvent *event) const
{
if (const DropMimeData *internalData = qobject_cast<const DropMimeData *>(event->mimeData())) {
if (const auto internalData = qobject_cast<const DropMimeData *>(event->mimeData())) {
return !internalData->values().isEmpty();
}
return false;
@@ -123,7 +123,7 @@ bool DropSupport::eventFilter(QObject *obj, QEvent *event)
bool accepted = false;
auto de = static_cast<QDropEvent *>(event);
if (!m_filterFunction || m_filterFunction(de, this)) {
const DropMimeData *fileDropMimeData = qobject_cast<const DropMimeData *>(de->mimeData());
const auto fileDropMimeData = qobject_cast<const DropMimeData *>(de->mimeData());
QList<FileSpec> tempFiles;
if (Utils::isFileDrop(de->mimeData(), &tempFiles)) {
event->accept();

View File

@@ -108,7 +108,7 @@ bool ElfMapper::map()
fdlen = file.size();
ustart = file.map(0, fdlen);
if (ustart == 0) {
if (ustart == nullptr) {
// Try reading the data into memory instead.
try {
raw = file.readAll();
@@ -221,7 +221,7 @@ ElfReader::Result ElfReader::readIt()
QTC_CHECK(data == mapper.ustart + (is64Bit ? 64 : 52));
if (quint64(e_shnum) * e_shentsize > fdlen) {
const QString reason = tr("announced %n sections, each %1 bytes, exceed file size", 0, e_shnum)
const QString reason = tr("announced %n sections, each %1 bytes, exceed file size", nullptr, e_shnum)
.arg(e_shentsize);
m_errorString = msgInvalidElfObject(m_binary, reason);
return Corrupt;

View File

@@ -91,7 +91,7 @@ public:
}
protected:
void paintEvent(QPaintEvent *)
void paintEvent(QPaintEvent *) override
{
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);

View File

@@ -52,9 +52,9 @@ FakeToolTip::FakeToolTip(QWidget *parent) :
p.setColor(QPalette::Inactive, QPalette::ButtonText, toolTipTextColor);
setPalette(p);
const int margin = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this);
const int margin = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, nullptr, this);
setContentsMargins(margin + 1, margin, margin, margin);
setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0);
setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, nullptr, this) / 255.0);
}
void FakeToolTip::paintEvent(QPaintEvent *)

View File

@@ -89,7 +89,7 @@ public:
FancyLineEdit *m_lineEdit;
IconButton *m_iconbutton[2];
HistoryCompleter *m_historyCompleter = 0;
HistoryCompleter *m_historyCompleter = nullptr;
FancyLineEdit::ValidationFunction m_validationFunction = &FancyLineEdit::validateWithValidator;
QString m_oldText;
QMenu *m_menu[2];
@@ -119,7 +119,7 @@ FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) :
m_iconbutton[i]->hide();
m_iconbutton[i]->setAutoHide(false);
m_menu[i] = 0;
m_menu[i] = nullptr;
m_menuTabFocusTrigger[i] = false;
m_iconEnabled[i] = false;
@@ -194,7 +194,7 @@ QAbstractButton *FancyLineEdit::button(FancyLineEdit::Side side) const
void FancyLineEdit::iconClicked()
{
IconButton *button = qobject_cast<IconButton *>(sender());
auto button = qobject_cast<IconButton *>(sender());
int index = -1;
for (int i = 0; i < 2; ++i)
if (d->m_iconbutton[i] == button)

View File

@@ -73,9 +73,9 @@ class DockWidget : public QDockWidget
public:
DockWidget(QWidget *inner, FancyMainWindow *parent, bool immutable = false);
bool eventFilter(QObject *, QEvent *event);
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
bool eventFilter(QObject *, QEvent *event) override;
void enterEvent(QEvent *event) override;
void leaveEvent(QEvent *event) override;
void handleMouseTimeout();
void handleToplevelChanged(bool floating);
@@ -98,13 +98,13 @@ public:
setFocusPolicy(Qt::NoFocus);
}
QSize sizeHint() const
QSize sizeHint() const override
{
ensurePolished();
int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this);
int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, nullptr, this);
if (!icon().isNull()) {
int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this);
QSize sz = icon().actualSize(QSize(iconSize, iconSize));
size += qMax(sz.width(), sz.height());
}
@@ -112,23 +112,23 @@ public:
return QSize(size, size);
}
QSize minimumSizeHint() const { return sizeHint(); }
QSize minimumSizeHint() const override { return sizeHint(); }
void enterEvent(QEvent *event)
void enterEvent(QEvent *event) override
{
if (isEnabled())
update();
QAbstractButton::enterEvent(event);
}
void leaveEvent(QEvent *event)
void leaveEvent(QEvent *event) override
{
if (isEnabled())
update();
QAbstractButton::leaveEvent(event);
}
void paintEvent(QPaintEvent *event);
void paintEvent(QPaintEvent *event) override;
};
void DockWidgetTitleButton::paintEvent(QPaintEvent *)
@@ -139,11 +139,11 @@ void DockWidgetTitleButton::paintEvent(QPaintEvent *)
opt.init(this);
opt.state |= QStyle::State_AutoRaise;
opt.icon = icon();
opt.subControls = 0;
opt.activeSubControls = 0;
opt.subControls = nullptr;
opt.activeSubControls = nullptr;
opt.features = QStyleOptionToolButton::None;
opt.arrowType = Qt::NoArrow;
int size = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
int size = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this);
opt.iconSize = QSize(size, size);
style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this);
}
@@ -194,7 +194,7 @@ public:
setProperty("managed_titlebar", 1);
}
void enterEvent(QEvent *event)
void enterEvent(QEvent *event) override
{
setActive(true);
QWidget::enterEvent(event);
@@ -219,13 +219,13 @@ public:
return m_active || !q->q->autoHideTitleBars();
}
QSize sizeHint() const
QSize sizeHint() const override
{
ensurePolished();
return isClickable() ? m_maximumActiveSize : m_maximumInactiveSize;
}
QSize minimumSizeHint() const
QSize minimumSizeHint() const override
{
ensurePolished();
return isClickable() ? m_minimumActiveSize : m_minimumInactiveSize;
@@ -292,7 +292,7 @@ DockWidget::DockWidget(QWidget *inner, FancyMainWindow *parent, bool immutable)
bool DockWidget::eventFilter(QObject *, QEvent *event)
{
if (!m_immutable && event->type() == QEvent::MouseMove && q->autoHideTitleBars()) {
QMouseEvent *me = static_cast<QMouseEvent *>(event);
auto me = static_cast<QMouseEvent *>(event);
int y = me->pos().y();
int x = me->pos().x();
int h = qMin(8, m_titleBar->m_floatButton->height());
@@ -350,11 +350,11 @@ void DockWidget::handleToplevelChanged(bool floating)
FancyMainWindowPrivate::FancyMainWindowPrivate(FancyMainWindow *parent) :
q(parent),
m_handleDockVisibilityChanges(true),
m_showCentralWidget(FancyMainWindow::tr("Central Widget"), 0),
m_menuSeparator1(0),
m_menuSeparator2(0),
m_resetLayoutAction(FancyMainWindow::tr("Reset to Default Layout"), 0),
m_autoHideTitleBars(FancyMainWindow::tr("Automatically Hide View Title Bars"), 0)
m_showCentralWidget(FancyMainWindow::tr("Central Widget"), nullptr),
m_menuSeparator1(nullptr),
m_menuSeparator2(nullptr),
m_resetLayoutAction(FancyMainWindow::tr("Reset to Default Layout"), nullptr),
m_autoHideTitleBars(FancyMainWindow::tr("Automatically Hide View Title Bars"), nullptr)
{
m_showCentralWidget.setCheckable(true);
m_showCentralWidget.setChecked(true);
@@ -391,7 +391,7 @@ FancyMainWindow::~FancyMainWindow()
QDockWidget *FancyMainWindow::addDockForWidget(QWidget *widget, bool immutable)
{
QTC_ASSERT(widget, return 0);
QTC_ASSERT(widget, return nullptr);
QTC_CHECK(widget->objectName().size());
QTC_CHECK(widget->windowTitle().size());
@@ -416,7 +416,7 @@ QDockWidget *FancyMainWindow::addDockForWidget(QWidget *widget, bool immutable)
void FancyMainWindow::onDockActionTriggered()
{
QDockWidget *dw = qobject_cast<QDockWidget *>(sender()->parent());
auto dw = qobject_cast<QDockWidget *>(sender()->parent());
if (dw) {
if (dw->isVisible())
dw->raise();

View File

@@ -63,9 +63,7 @@ static bool checkPath(const QString &candidate, FileInProjectFinder::FindMode fi
\endlist
*/
FileInProjectFinder::FileInProjectFinder()
{
}
FileInProjectFinder::FileInProjectFinder() = default;
static QString stripTrailingSlashes(const QString &path)
{

View File

@@ -42,14 +42,14 @@ static inline QString msgCanceled(const QString &searchTerm, int numMatches, int
{
return QCoreApplication::translate("Utils::FileSearch",
"%1: canceled. %n occurrences found in %2 files.",
0, numMatches).arg(searchTerm).arg(numFilesSearched);
nullptr, numMatches).arg(searchTerm).arg(numFilesSearched);
}
static inline QString msgFound(const QString &searchTerm, int numMatches, int numFilesSearched)
{
return QCoreApplication::translate("Utils::FileSearch",
"%1: %n occurrences found in %2 files.",
0, numMatches).arg(searchTerm).arg(numFilesSearched);
nullptr, numMatches).arg(searchTerm).arg(numFilesSearched);
}
namespace {
@@ -301,7 +301,7 @@ struct SearchState
{
SearchState(const QString &term, FileIterator *iterator) : searchTerm(term), files(iterator) {}
QString searchTerm;
FileIterator *files = 0;
FileIterator *files = nullptr;
FileSearchResultList cachedResults;
int numFilesSearched = 0;
int numMatches = 0;
@@ -649,7 +649,7 @@ SubDirFileIterator::SubDirFileIterator(const QStringList &directories, const QSt
: m_filterFiles(filterFilesFunction(filters, exclusionFilters)),
m_progress(0)
{
m_encoding = (encoding == 0 ? QTextCodec::codecForLocale() : encoding);
m_encoding = (encoding == nullptr ? QTextCodec::codecForLocale() : encoding);
qreal maxPer = qreal(MAX_PROGRESS) / directories.count();
foreach (const QString &directoryEntry, directories) {
if (!directoryEntry.isEmpty()) {

View File

@@ -87,32 +87,32 @@ class FileSystemWatcherStaticData
{
public:
FileSystemWatcherStaticData() :
maxFileOpen(getFileLimit()) , m_objectCount(0), m_watcher(0) {}
maxFileOpen(getFileLimit()) {}
quint64 maxFileOpen;
int m_objectCount;
int m_objectCount = 0;
QHash<QString, int> m_fileCount;
QHash<QString, int> m_directoryCount;
QFileSystemWatcher *m_watcher;
QFileSystemWatcher *m_watcher = nullptr;
};
typedef QMap<int, FileSystemWatcherStaticData> FileSystemWatcherStaticDataMap;
using FileSystemWatcherStaticDataMap = QMap<int, FileSystemWatcherStaticData>;
Q_GLOBAL_STATIC(FileSystemWatcherStaticDataMap, fileSystemWatcherStaticDataMap)
class WatchEntry
{
public:
typedef FileSystemWatcher::WatchMode WatchMode;
using WatchMode = FileSystemWatcher::WatchMode;
explicit WatchEntry(const QString &file, WatchMode wm) :
watchMode(wm), modifiedTime(QFileInfo(file).lastModified()) {}
WatchEntry() : watchMode(FileSystemWatcher::WatchAllChanges) {}
WatchEntry() = default;
bool trigger(const QString &fileName);
WatchMode watchMode;
WatchMode watchMode = FileSystemWatcher::WatchAllChanges;
QDateTime modifiedTime;
};
@@ -131,13 +131,13 @@ bool WatchEntry::trigger(const QString &fileName)
return false;
}
typedef QHash<QString, WatchEntry> WatchEntryMap;
typedef WatchEntryMap::iterator WatchEntryMapIterator;
using WatchEntryMap = QHash<QString, WatchEntry>;
using WatchEntryMapIterator = WatchEntryMap::iterator;
class FileSystemWatcherPrivate
{
public:
explicit FileSystemWatcherPrivate(int id) : m_id(id), m_staticData(0) {}
explicit FileSystemWatcherPrivate(int id) : m_id(id), m_staticData(nullptr) {}
WatchEntryMap m_files;
WatchEntryMap m_directories;
@@ -208,7 +208,7 @@ FileSystemWatcher::~FileSystemWatcher()
if (--(d->m_staticData->m_objectCount) == 0) {
delete d->m_staticData->m_watcher;
d->m_staticData->m_watcher = 0;
d->m_staticData->m_watcher = nullptr;
d->m_staticData->m_fileCount.clear();
d->m_staticData->m_directoryCount.clear();
if (debug)

View File

@@ -305,7 +305,7 @@ QString FileUtils::normalizePathName(const QString &name)
{
#ifdef Q_OS_WIN
const QString nativeSeparatorName(QDir::toNativeSeparators(name));
const LPCTSTR nameC = reinterpret_cast<LPCTSTR>(nativeSeparatorName.utf16()); // MinGW
const auto nameC = reinterpret_cast<LPCTSTR>(nativeSeparatorName.utf16()); // MinGW
PIDLIST_ABSOLUTE file;
HRESULT hr = SHParseDisplayName(nameC, NULL, &file, 0, NULL);
if (FAILED(hr))
@@ -514,7 +514,7 @@ bool FileSaver::finalize()
if (!m_isSafe)
return FileSaverBase::finalize();
SaveFile *sf = static_cast<SaveFile *>(m_file.get());
auto sf = static_cast<SaveFile *>(m_file.get());
if (m_hasError) {
if (sf->isOpen())
sf->rollback();
@@ -529,7 +529,7 @@ TempFileSaver::TempFileSaver(const QString &templ)
: m_autoRemove(true)
{
m_file.reset(new QTemporaryFile{});
QTemporaryFile *tempFile = static_cast<QTemporaryFile *>(m_file.get());
auto tempFile = static_cast<QTemporaryFile *>(m_file.get());
if (!templ.isEmpty())
tempFile->setFileTemplate(templ);
tempFile->setAutoRemove(false);

View File

@@ -44,16 +44,11 @@ namespace Utils {
class FileWizardPagePrivate
{
public:
FileWizardPagePrivate();
FileWizardPagePrivate() = default;
Ui::WizardPage m_ui;
bool m_complete;
bool m_complete = false;
};
FileWizardPagePrivate::FileWizardPagePrivate() :
m_complete(false)
{
}
FileWizardPage::FileWizardPage(QWidget *parent) :
WizardPage(parent),
d(new FileWizardPagePrivate)

View File

@@ -84,12 +84,12 @@ QLayoutItem *FlowLayout::takeAt(int index)
if (index >= 0 && index < itemList.size())
return itemList.takeAt(index);
else
return 0;
return nullptr;
}
Qt::Orientations FlowLayout::expandingDirections() const
{
return 0;
return nullptr;
}
bool FlowLayout::hasHeightForWidth() const
@@ -167,8 +167,8 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
if (!parent) {
return -1;
} else if (parent->isWidgetType()) {
QWidget *pw = static_cast<QWidget *>(parent);
return pw->style()->pixelMetric(pm, 0, pw);
auto pw = static_cast<QWidget *>(parent);
return pw->style()->pixelMetric(pm, nullptr, pw);
} else {
return static_cast<QLayout *>(parent)->spacing();
}

View File

@@ -85,9 +85,7 @@
namespace Utils {
Guard::Guard()
{
}
Guard::Guard() = default;
Guard::~Guard()
{

View File

@@ -57,18 +57,18 @@ bool HeaderViewStretcher::eventFilter(QObject *obj, QEvent *ev)
{
if (obj == parent()) {
if (ev->type() == QEvent::Show) {
QHeaderView *hv = qobject_cast<QHeaderView*>(obj);
auto hv = qobject_cast<QHeaderView*>(obj);
for (int i = 0; i < hv->count(); ++i)
hv->setSectionResizeMode(i, QHeaderView::Interactive);
} else if (ev->type() == QEvent::Hide) {
QHeaderView *hv = qobject_cast<QHeaderView*>(obj);
auto hv = qobject_cast<QHeaderView*>(obj);
for (int i = 0; i < hv->count(); ++i)
hv->setSectionResizeMode(i, i == m_columnToStretch
? QHeaderView::Stretch : QHeaderView::ResizeToContents);
} else if (ev->type() == QEvent::Resize) {
QHeaderView *hv = qobject_cast<QHeaderView*>(obj);
auto hv = qobject_cast<QHeaderView*>(obj);
if (hv->sectionResizeMode(m_columnToStretch) == QHeaderView::Interactive) {
QResizeEvent *re = static_cast<QResizeEvent*>(ev);
auto re = static_cast<QResizeEvent*>(ev);
int diff = re->size().width() - re->oldSize().width() ;
hv->resizeSection(m_columnToStretch, qMax(32, hv->sectionSize(m_columnToStretch) + diff));
}

View File

@@ -135,7 +135,7 @@ int HighlightingItemDelegate::drawLineNumber(QPainter *painter, const QStyleOpti
opt.palette.setColor(cg, QPalette::Text, Qt::darkGray);
const QStyle *style = QApplication::style();
const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, nullptr) + 1;
const QRect rowRect
= lineNumberAreaRect.adjusted(-textMargin, 0,
@@ -263,7 +263,7 @@ void HighlightingItemDelegate::drawDisplay(QPainter *painter,
const QWidget *widget = option.widget;
QStyle *style = widget ? widget->style() : QApplication::style();
const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1;
const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding
const bool wrapText = opt.features & QStyleOptionViewItem::WrapText;
QTextOption textOption;

View File

@@ -41,14 +41,14 @@
namespace Utils {
namespace Internal {
static QSettings *theSettings = 0;
static QSettings *theSettings = nullptr;
class HistoryCompleterPrivate : public QAbstractListModel
{
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
void clearHistory();
void addEntry(const QString &str);
@@ -69,7 +69,7 @@ public:
, icon(Icons::EDIT_CLEAR.icon())
{}
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
{
// from QHistoryCompleter
QStyleOptionViewItem optCopy = option;
@@ -109,7 +109,7 @@ public:
}
private:
void mousePressEvent(QMouseEvent *event)
void mousePressEvent(QMouseEvent *event) override
{
const QSize clearButtonSize = delegate->clearIconSize;
if (clearButtonSize.isValid()) {

View File

@@ -47,10 +47,10 @@ static QPixmap maskToColorAndAlpha(const QPixmap &mask, const QColor &color)
{
QImage result(mask.toImage().convertToFormat(QImage::Format_ARGB32));
result.setDevicePixelRatio(mask.devicePixelRatio());
QRgb *bitsStart = reinterpret_cast<QRgb*>(result.bits());
auto bitsStart = reinterpret_cast<QRgb*>(result.bits());
const QRgb *bitsEnd = bitsStart + result.width() * result.height();
const QRgb tint = color.rgb() & 0x00ffffff;
const QRgb alpha = QRgb(color.alpha());
const auto alpha = QRgb(color.alpha());
for (QRgb *pixel = bitsStart; pixel < bitsEnd; ++pixel) {
QRgb pixelAlpha = (((~*pixel) & 0xff) * alpha) >> 8;
*pixel = (pixelAlpha << 24) | tint;
@@ -58,8 +58,8 @@ static QPixmap maskToColorAndAlpha(const QPixmap &mask, const QColor &color)
return QPixmap::fromImage(result);
}
typedef QPair<QPixmap, QColor> MaskAndColor;
typedef QList<MaskAndColor> MasksAndColors;
using MaskAndColor = QPair<QPixmap, QColor>;
using MasksAndColors = QList<MaskAndColor>;
static MasksAndColors masksAndColors(const Icon &icon, int dpr)
{
MasksAndColors result;
@@ -154,9 +154,7 @@ static QPixmap masksToIcon(const MasksAndColors &masks, const QPixmap &combinedM
return result;
}
Icon::Icon()
{
}
Icon::Icon() = default;
Icon::Icon(std::initializer_list<IconMaskAndColor> args, Icon::IconStyleOptions style)
: QVector<IconMaskAndColor>(args)

View File

@@ -46,14 +46,13 @@ JsonValue::JsonValue(Kind kind)
: m_kind(kind)
{}
JsonValue::~JsonValue()
{}
JsonValue::~JsonValue() = default;
JsonValue *JsonValue::create(const QString &s, JsonMemoryPool *pool)
{
const QJsonDocument document = QJsonDocument::fromJson(s.toUtf8());
if (document.isNull())
return 0;
return nullptr;
return build(document.toVariant(), pool);
}
@@ -92,14 +91,14 @@ JsonValue *JsonValue::build(const QVariant &variant, JsonMemoryPool *pool)
switch (variant.type()) {
case QVariant::List: {
JsonArrayValue *newValue = new (pool) JsonArrayValue;
auto newValue = new (pool) JsonArrayValue;
foreach (const QVariant &element, variant.toList())
newValue->addElement(build(element, pool));
return newValue;
}
case QVariant::Map: {
JsonObjectValue *newValue = new (pool) JsonObjectValue;
auto newValue = new (pool) JsonObjectValue;
const QVariantMap variantMap = variant.toMap();
for (QVariantMap::const_iterator it = variantMap.begin(); it != variantMap.end(); ++it)
newValue->addMember(it.key(), build(it.value(), pool));
@@ -125,7 +124,7 @@ JsonValue *JsonValue::build(const QVariant &variant, JsonMemoryPool *pool)
break;
}
return 0;
return nullptr;
}
@@ -295,7 +294,7 @@ JsonObjectValue *JsonSchema::propertySchema(const QString &property,
if (JsonObjectValue *base = resolveBase(v))
return propertySchema(property, base);
return 0;
return nullptr;
}
bool JsonSchema::hasPropertySchema(const QString &property) const
@@ -526,14 +525,14 @@ bool JsonSchema::maybeSchemaName(const QString &s)
JsonObjectValue *JsonSchema::rootValue() const
{
QTC_ASSERT(!m_schemas.isEmpty(), return 0);
QTC_ASSERT(!m_schemas.isEmpty(), return nullptr);
return m_schemas.first().m_value;
}
JsonObjectValue *JsonSchema::currentValue() const
{
QTC_ASSERT(!m_schemas.isEmpty(), return 0);
QTC_ASSERT(!m_schemas.isEmpty(), return nullptr);
return m_schemas.last().m_value;
}
@@ -616,14 +615,14 @@ JsonObjectValue *JsonSchema::resolveBase(JsonObjectValue *ov) const
}
}
return 0;
return nullptr;
}
JsonStringValue *JsonSchema::getStringValue(const QString &name, JsonObjectValue *value)
{
JsonValue *v = value->member(name);
if (!v)
return 0;
return nullptr;
return v->toString();
}
@@ -632,7 +631,7 @@ JsonObjectValue *JsonSchema::getObjectValue(const QString &name, JsonObjectValue
{
JsonValue *v = value->member(name);
if (!v)
return 0;
return nullptr;
return v->toObject();
}
@@ -641,7 +640,7 @@ JsonBooleanValue *JsonSchema::getBooleanValue(const QString &name, JsonObjectVal
{
JsonValue *v = value->member(name);
if (!v)
return 0;
return nullptr;
return v->toBoolean();
}
@@ -650,7 +649,7 @@ JsonArrayValue *JsonSchema::getArrayValue(const QString &name, JsonObjectValue *
{
JsonValue *v = value->member(name);
if (!v)
return 0;
return nullptr;
return v->toArray();
}
@@ -659,7 +658,7 @@ JsonDoubleValue *JsonSchema::getDoubleValue(const QString &name, JsonObjectValue
{
JsonValue *v = value->member(name);
if (!v)
return 0;
return nullptr;
return v->toDouble();
}
@@ -717,7 +716,7 @@ JsonSchema *JsonSchemaManager::schemaByName(const QString &baseName) const
it = m_schemas.find(baseName);
if (it == m_schemas.end())
return 0;
return nullptr;
JsonSchemaData *schemaData = &it.value();
if (!schemaData->m_schema) {
@@ -743,5 +742,5 @@ JsonSchema *JsonSchemaManager::parseSchema(const QString &schemaFileName) const
return new JsonSchema(json->toObject(), this);
}
return 0;
return nullptr;
}

View File

@@ -49,11 +49,9 @@ const char kFileBaseNamePostfix[] = ":FileBaseName";
class MacroExpanderPrivate : public AbstractMacroExpander
{
public:
MacroExpanderPrivate()
: m_accumulating(false), m_aborted(false), m_lockDepth(0)
{}
MacroExpanderPrivate() = default;
bool resolveMacro(const QString &name, QString *ret, QSet<AbstractMacroExpander *> &seen)
bool resolveMacro(const QString &name, QString *ret, QSet<AbstractMacroExpander *> &seen) override
{
// Prevent loops:
const int count = seen.count();
@@ -113,10 +111,10 @@ public:
QMap<QByteArray, QString> m_descriptions;
QString m_displayName;
QVector<MacroExpanderProvider> m_subProviders;
bool m_accumulating;
bool m_accumulating = false;
bool m_aborted;
int m_lockDepth;
bool m_aborted = false;
int m_lockDepth = 0;
};
} // Internal

View File

@@ -328,7 +328,7 @@ MimeDatabase::MimeDatabase() :
*/
MimeDatabase::~MimeDatabase()
{
d = 0;
d = nullptr;
}
void Utils::addMimeTypes(const QString &fileName, const QByteArray &data)

View File

@@ -98,7 +98,7 @@ public:
quint32 number;
quint32 numberMask;
typedef bool (*MatchFunction)(const MimeMagicRulePrivate *d, const QByteArray &data);
using MatchFunction = bool (*)(const MimeMagicRulePrivate*, const QByteArray&);
MatchFunction matchFunction;
};
@@ -263,7 +263,7 @@ MimeMagicRule::MimeMagicRule(MimeMagicRule::Type theType,
d->startPos = theStartPos;
d->endPos = theEndPos;
d->mask = theMask;
d->matchFunction = 0;
d->matchFunction = nullptr;
if (d->value.isEmpty()) {
d->type = Invalid;
@@ -365,9 +365,7 @@ MimeMagicRule::MimeMagicRule(const MimeMagicRule &other) :
{
}
MimeMagicRule::~MimeMagicRule()
{
}
MimeMagicRule::~MimeMagicRule() = default;
MimeMagicRule &MimeMagicRule::operator=(const MimeMagicRule &other)
{

View File

@@ -139,10 +139,7 @@ MimeType::MimeType() :
\fn MimeType::MimeType(const MimeType &other);
Constructs this MimeType object as a copy of \a other.
*/
MimeType::MimeType(const MimeType &other) :
d(other.d)
{
}
MimeType::MimeType(const MimeType &other) = default;
/*!
\fn MimeType &MimeType::operator=(const MimeType &other);
@@ -181,9 +178,7 @@ MimeType::MimeType(const MimeTypePrivate &dd) :
\fn MimeType::~MimeType();
Destroys the MimeType object, and releases the d pointer.
*/
MimeType::~MimeType()
{
}
MimeType::~MimeType() = default;
/*!
\fn bool MimeType::operator==(const MimeType &other) const;

View File

@@ -295,7 +295,7 @@ bool MimeTypeParserBase::parse(const QByteArray &content, const QString &fileNam
}
break;
case ParseMagicMatchRule: {
MimeMagicRule *rule = 0;
MimeMagicRule *rule = nullptr;
if (!createMagicMatchRule(atts, errorMessage, rule))
return false;
QList<MimeMagicRule> *ruleList;

View File

@@ -47,12 +47,12 @@
namespace Utils {
static NetworkAccessManager *namInstance = 0;
static NetworkAccessManager *namInstance = nullptr;
void cleanupNetworkAccessManager()
{
delete namInstance;
namInstance = 0;
namInstance = nullptr;
}
NetworkAccessManager *NetworkAccessManager::instance()

View File

@@ -51,34 +51,24 @@ struct NewClassWidgetPrivate {
QString m_headerExtension;
QString m_sourceExtension;
QString m_formExtension;
bool m_valid;
bool m_classEdited;
bool m_valid = false;
bool m_classEdited = false;
// Store the "visible" values to prevent the READ accessors from being
// fooled by a temporarily hidden widget
bool m_baseClassInputVisible;
bool m_formInputVisible;
bool m_headerInputVisible;
bool m_sourceInputVisible;
bool m_pathInputVisible;
bool m_qobjectCheckBoxVisible;
bool m_formInputCheckable;
bool m_baseClassInputVisible = true;
bool m_formInputVisible = true;
bool m_headerInputVisible = true;
bool m_sourceInputVisible = true;
bool m_pathInputVisible = true;
bool m_qobjectCheckBoxVisible = false;
bool m_formInputCheckable = false;
QRegExp m_classNameValidator;
};
NewClassWidgetPrivate:: NewClassWidgetPrivate() :
m_headerExtension(QLatin1Char('h')),
m_sourceExtension(QLatin1String("cpp")),
m_formExtension(QLatin1String("ui")),
m_valid(false),
m_classEdited(false),
m_baseClassInputVisible(true),
m_formInputVisible(true),
m_headerInputVisible(true),
m_sourceInputVisible(true),
m_pathInputVisible(true),
m_qobjectCheckBoxVisible(false),
m_formInputCheckable(false)
m_formExtension(QLatin1String("ui"))
{
}

View File

@@ -38,7 +38,7 @@ class OutputFormatterPrivate
{
public:
OutputFormatterPrivate()
: plainTextEdit(0), overwriteOutput(false)
: plainTextEdit(nullptr), overwriteOutput(false)
{}
QPlainTextEdit *plainTextEdit;

View File

@@ -102,7 +102,7 @@ bool BinaryVersionToolTipEventFilter::eventFilter(QObject *o, QEvent *e)
{
if (e->type() != QEvent::ToolTip)
return false;
QLineEdit *le = qobject_cast<QLineEdit *>(o);
auto le = qobject_cast<QLineEdit *>(o);
QTC_ASSERT(le, return false);
const QString binary = le->text();
@@ -674,7 +674,7 @@ QString PathChooser::toolVersion(const QString &binary, const QStringList &argum
void PathChooser::installLineEditVersionToolTip(QLineEdit *le, const QStringList &arguments)
{
BinaryVersionToolTipEventFilter *ef = new BinaryVersionToolTipEventFilter(le);
auto ef = new BinaryVersionToolTipEventFilter(le);
ef->setArguments(arguments);
}

View File

@@ -68,7 +68,7 @@ const int PathListEditor::lastInsertButtonIndex = 0;
class PathListPlainTextEdit : public QPlainTextEdit {
public:
explicit PathListPlainTextEdit(QWidget *parent = 0);
explicit PathListPlainTextEdit(QWidget *parent = nullptr);
protected:
void insertFromMimeData (const QMimeData *source) override;
};
@@ -149,7 +149,7 @@ QPushButton *PathListEditor::addButton(const QString &text, QObject *parent,
QPushButton *PathListEditor::insertButton(int index /* -1 */, const QString &text, QObject *parent,
std::function<void()> slotFunc)
{
QPushButton *rc = new QPushButton(text, this);
auto rc = new QPushButton(text, this);
QObject::connect(rc, &QPushButton::pressed, parent, slotFunc);
d->buttonLayout->insertWidget(index, rc);
return rc;

View File

@@ -108,7 +108,7 @@ namespace Utils {
struct Context // Basic context containing element name string constants.
{
Context() {}
Context() = default;
const QString qtCreatorElement = QString("qtcreator");
const QString dataElement = QString("data");
const QString variableElement = QString("variable");
@@ -281,7 +281,7 @@ QString ParseContext::formatWarning(const QXmlStreamReader &r, const QString &me
{
QString result = QLatin1String("Warning reading ");
if (const QIODevice *device = r.device())
if (const QFile *file = qobject_cast<const QFile *>(device))
if (const auto file = qobject_cast<const QFile *>(device))
result += QDir::toNativeSeparators(file->fileName()) + QLatin1Char(':');
result += QString::number(r.lineNumber());
result += QLatin1String(": ");
@@ -327,9 +327,7 @@ QVariant ParseContext::readSimpleValue(QXmlStreamReader &r, const QXmlStreamAttr
// =================================== PersistentSettingsReader
PersistentSettingsReader::PersistentSettingsReader()
{
}
PersistentSettingsReader::PersistentSettingsReader() = default;
QVariant PersistentSettingsReader::restoreValue(const QString &variable, const QVariant &defaultValue) const
{
@@ -417,7 +415,7 @@ PersistentSettingsWriter::PersistentSettingsWriter(const FileName &fileName, con
PersistentSettingsWriter::~PersistentSettingsWriter()
{
write(m_savedData, 0);
write(m_savedData, nullptr);
}
bool PersistentSettingsWriter::save(const QVariantMap &data, QString *errorString) const

View File

@@ -35,7 +35,7 @@ namespace Utils {
namespace Internal {
namespace {
typedef QPair<Port, Port> Range;
using Range = QPair<Port, Port>;
class PortsSpecParser
{

View File

@@ -47,7 +47,7 @@ const wchar_t szTitle[] = L"qtcctrlcstub";
const wchar_t szWindowClass[] = L"wcqtcctrlcstub";
UINT uiShutDownWindowMessage;
UINT uiInterruptMessage;
HWND hwndMain = 0;
HWND hwndMain = nullptr;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
BOOL WINAPI shutdownHandler(DWORD dwCtrlType);
@@ -68,7 +68,7 @@ int main(int argc, char **)
WNDCLASSEX wcex = {0};
wcex.cbSize = sizeof(wcex);
wcex.lpfnWndProc = WndProc;
wcex.hInstance = GetModuleHandle(0);
wcex.hInstance = GetModuleHandle(nullptr);
wcex.lpszClassName = szWindowClass;
if (!RegisterClassEx(&wcex))
return 1;
@@ -156,7 +156,7 @@ BOOL WINAPI interruptHandler(DWORD /*dwCtrlType*/)
DWORD WINAPI processWatcherThread(LPVOID lpParameter)
{
HANDLE hProcess = reinterpret_cast<HANDLE>(lpParameter);
auto hProcess = reinterpret_cast<HANDLE>(lpParameter);
WaitForSingleObject(hProcess, INFINITE);
DWORD dwExitCode;
if (!GetExitCodeProcess(hProcess, &dwExitCode))

View File

@@ -29,8 +29,8 @@ using namespace Utils;
ProxyAction::ProxyAction(QObject *parent) :
QAction(parent),
m_action(0),
m_attributes(0),
m_action(nullptr),
m_attributes(nullptr),
m_showShortcut(false),
m_block(false)
{
@@ -178,7 +178,7 @@ QString ProxyAction::stringWithAppendedShortcut(const QString &str, const QKeySe
ProxyAction *ProxyAction::proxyActionWithIcon(QAction *original, const QIcon &newIcon)
{
ProxyAction *proxyAction = new ProxyAction(original);
auto proxyAction = new ProxyAction(original);
proxyAction->setAction(original);
proxyAction->setIcon(newIcon);
proxyAction->setAttribute(UpdateText);

View File

@@ -236,9 +236,9 @@ void QtColorButton::mouseMoveEvent(QMouseEvent *event)
#ifndef QT_NO_DRAGANDDROP
if (event->buttons() & Qt::LeftButton &&
(d_ptr->m_dragStart - event->pos()).manhattanLength() > QApplication::startDragDistance()) {
QMimeData *mime = new QMimeData;
auto mime = new QMimeData;
mime->setColorData(color());
QDrag *drg = new QDrag(this);
auto drg = new QDrag(this);
drg->setMimeData(mime);
drg->setPixmap(d_ptr->generatePixmap());
setDown(false);

View File

@@ -56,7 +56,7 @@ namespace Utils {
SavedAction::SavedAction(QObject *parent)
: QAction(parent)
{
m_widget = 0;
m_widget = nullptr;
connect(this, &QAction::triggered, this, &SavedAction::actionTriggered);
}
@@ -285,7 +285,7 @@ void SavedAction::connectWidget(QWidget *widget, ApplyMode applyMode)
*/
void SavedAction::disconnectWidget()
{
m_widget = 0;
m_widget = nullptr;
}
void SavedAction::apply(QSettings *s)
@@ -335,7 +335,7 @@ void SavedAction::actionTriggered(bool)
if (actionGroup() && actionGroup()->isExclusive()) {
// FIXME: should be taken care of more directly
foreach (QAction *act, actionGroup()->actions())
if (SavedAction *dact = qobject_cast<SavedAction *>(act))
if (auto dact = qobject_cast<SavedAction *>(act))
dact->setValue(bool(act == this));
}
}

View File

@@ -36,7 +36,7 @@
namespace Utils {
QFile::Permissions SaveFile::m_umask = 0;
QFile::Permissions SaveFile::m_umask = nullptr;
SaveFile::SaveFile(const QString &filename) :
m_finalFileName(filename), m_finalized(true)

View File

@@ -41,7 +41,7 @@ namespace Utils {
SettingsSelector::SettingsSelector(QWidget *parent) :
QWidget(parent)
{
QHBoxLayout *layout = new QHBoxLayout(this);
auto layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(6);
@@ -77,8 +77,7 @@ SettingsSelector::SettingsSelector(QWidget *parent) :
this, &SettingsSelector::currentChanged);
}
SettingsSelector::~SettingsSelector()
{ }
SettingsSelector::~SettingsSelector() = default;
void SettingsSelector::setConfigurationModel(QAbstractItemModel *model)
{

View File

@@ -314,7 +314,7 @@ void ShellCommand::run(QFutureInterface<void> &future)
}
if (d->m_progressParser)
d->m_progressParser->setFuture(0);
d->m_progressParser->setFuture(nullptr);
// As it is used asynchronously, we need to delete ourselves
this->deleteLater();
}
@@ -503,7 +503,7 @@ void ShellCommand::setOutputProxyFactory(const std::function<OutputProxy *()> &f
}
ProgressParser::ProgressParser() :
m_future(0),
m_future(nullptr),
m_futureMutex(new QMutex)
{ }

View File

@@ -35,7 +35,7 @@
namespace Utils {
StatusLabel::StatusLabel(QWidget *parent) : QLabel(parent), m_timer(0)
StatusLabel::StatusLabel(QWidget *parent) : QLabel(parent), m_timer(nullptr)
{
// A manual size let's us shrink below minimum text width which is what
// we want in [fake] status bars.

View File

@@ -376,7 +376,7 @@ QPixmap StyleHelper::disabledSideBarIcon(const QPixmap &enabledicon)
{
QImage im = enabledicon.toImage().convertToFormat(QImage::Format_ARGB32);
for (int y=0; y<im.height(); ++y) {
QRgb *scanLine = reinterpret_cast<QRgb*>(im.scanLine(y));
auto scanLine = reinterpret_cast<QRgb*>(im.scanLine(y));
for (int x=0; x<im.width(); ++x) {
QRgb pixel = *scanLine;
char intensity = char(qGray(pixel));

View File

@@ -317,8 +317,8 @@ SynchronousProcess::SynchronousProcess() :
SynchronousProcess::~SynchronousProcess()
{
disconnect(&d->m_timer, 0, this, 0);
disconnect(&d->m_process, 0, this, 0);
disconnect(&d->m_timer, nullptr, this, nullptr);
disconnect(&d->m_process, nullptr, this, nullptr);
delete d;
}
@@ -540,10 +540,10 @@ static inline bool askToKill(const QString &binary = QString())
msg += QLatin1Char(' ');
msg += SynchronousProcess::tr("Would you like to terminate it?");
// Restore the cursor that is set to wait while running.
const bool hasOverrideCursor = QApplication::overrideCursor() != 0;
const bool hasOverrideCursor = QApplication::overrideCursor() != nullptr;
if (hasOverrideCursor)
QApplication::restoreOverrideCursor();
QMessageBox::StandardButton answer = QMessageBox::question(0, title, msg, QMessageBox::Yes|QMessageBox::No);
QMessageBox::StandardButton answer = QMessageBox::question(nullptr, title, msg, QMessageBox::Yes|QMessageBox::No);
if (hasOverrideCursor)
QApplication::setOverrideCursor(Qt::WaitCursor);
return answer == QMessageBox::Yes;
@@ -616,7 +616,7 @@ void SynchronousProcess::processStdErr(bool emitSignals)
QSharedPointer<QProcess> SynchronousProcess::createProcess(unsigned flags)
{
TerminalControllingProcess *process = new TerminalControllingProcess;
auto process = new TerminalControllingProcess;
process->setFlags(flags);
return QSharedPointer<QProcess>(process);
}

View File

@@ -69,7 +69,7 @@ QDebug operator<<(QDebug d, const TextFileFormat &format)
*/
TextFileFormat::TextFileFormat() :
lineTerminationMode(NativeLineTerminator), hasUtf8Bom(false), codec(0)
lineTerminationMode(NativeLineTerminator), hasUtf8Bom(false), codec(nullptr)
{
}
@@ -83,7 +83,7 @@ TextFileFormat TextFileFormat::detect(const QByteArray &data)
if (data.isEmpty())
return result;
const int bytesRead = data.size();
const unsigned char *buf = reinterpret_cast<const unsigned char *>(data.constData());
const auto buf = reinterpret_cast<const unsigned char *>(data.constData());
// code taken from qtextstream
if (bytesRead >= 4 && ((buf[0] == 0xff && buf[1] == 0xfe && buf[2] == 0 && buf[3] == 0)
|| (buf[0] == 0 && buf[1] == 0 && buf[2] == 0xfe && buf[3] == 0xff))) {
@@ -202,7 +202,7 @@ bool TextFileFormat::decode(const QByteArray &data, QStringList *target) const
template <class Target>
TextFileFormat::ReadResult readTextFile(const QString &fileName, const QTextCodec *defaultCodec,
Target *target, TextFileFormat *format, QString *errorString,
QByteArray *decodingErrorSampleIn = 0)
QByteArray *decodingErrorSampleIn = nullptr)
{
if (decodingErrorSampleIn)
decodingErrorSampleIn->clear();

View File

@@ -36,7 +36,7 @@
namespace Utils {
static Theme *m_creatorTheme = 0;
static Theme *m_creatorTheme = nullptr;
ThemePrivate::ThemePrivate()
{

View File

@@ -120,11 +120,11 @@ TextTip::TextTip(QWidget *parent) : QTipLabel(parent)
setForegroundRole(QPalette::ToolTipText);
setBackgroundRole(QPalette::ToolTipBase);
ensurePolished();
setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this));
setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, nullptr, this));
setFrameStyle(QFrame::NoFrame);
setAlignment(Qt::AlignLeft);
setIndent(1);
setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0);
setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, nullptr, this) / 255.0);
}
static bool likelyContainsLink(const QString &s)

View File

@@ -45,7 +45,7 @@
using namespace Utils;
using namespace Internal;
ToolTip::ToolTip() : m_tip(0), m_widget(0)
ToolTip::ToolTip() : m_tip(nullptr), m_widget(nullptr)
{
connect(&m_showTimer, &QTimer::timeout, this, &ToolTip::hideTipImmediately);
connect(&m_hideDelayTimer, &QTimer::timeout, this, &ToolTip::hideTipImmediately);
@@ -53,7 +53,7 @@ ToolTip::ToolTip() : m_tip(0), m_widget(0)
ToolTip::~ToolTip()
{
m_tip = 0;
m_tip = nullptr;
}
ToolTip *ToolTip::instance()
@@ -109,7 +109,7 @@ bool ToolTip::pinToolTip(QWidget *w, QWidget *parent)
// Find the parent WidgetTip, tell it to pin/release the
// widget and close.
for (QWidget *p = w->parentWidget(); p ; p = p->parentWidget()) {
if (WidgetTip *wt = qobject_cast<WidgetTip *>(p)) {
if (auto wt = qobject_cast<WidgetTip *>(p)) {
wt->pinToolTipWidget(parent);
ToolTip::hide();
return true;
@@ -234,7 +234,7 @@ void ToolTip::hideTipImmediately()
if (m_tip) {
m_tip->close();
m_tip->deleteLater();
m_tip = 0;
m_tip = nullptr;
}
m_showTimer.stop();
m_hideDelayTimer.stop();
@@ -246,7 +246,7 @@ void ToolTip::showInternal(const QPoint &pos, const QVariant &content,
int typeId, QWidget *w, const QString &helpId, const QRect &rect)
{
if (acceptShow(content, typeId, pos, w, helpId, rect)) {
QWidget *target = 0;
QWidget *target = nullptr;
if (HostOsInfo::isWindowsHost())
target = QApplication::desktop()->screen(Internal::screenNumber(pos, w));
else

View File

@@ -606,20 +606,20 @@ namespace Utils {
// TreeItem
//
TreeItem::TreeItem()
: m_parent(0), m_model(0)
: m_parent(nullptr), m_model(nullptr)
{
}
TreeItem::~TreeItem()
{
QTC_CHECK(m_parent == 0);
QTC_CHECK(m_model == 0);
QTC_CHECK(m_parent == nullptr);
QTC_CHECK(m_model == nullptr);
removeChildren();
}
TreeItem *TreeItem::childAt(int pos) const
{
QTC_ASSERT(pos >= 0, return 0);
QTC_ASSERT(pos >= 0, return nullptr);
return pos < childCount() ? *(begin() + pos) : nullptr;
}
@@ -837,7 +837,7 @@ void TreeItem::forChildrenAtLevel(int level, const std::function<void(TreeItem *
TreeItem *TreeItem::findChildAtLevel(int level, const std::function<bool(TreeItem *)> &pred) const
{
QTC_ASSERT(level > 0, return 0);
QTC_ASSERT(level > 0, return nullptr);
if (level == 1) {
for (TreeItem *item : *this)
if (pred(item))
@@ -848,7 +848,7 @@ TreeItem *TreeItem::findChildAtLevel(int level, const std::function<bool(TreeIte
return found;
}
}
return 0;
return nullptr;
}
TreeItem *TreeItem::findAnyChild(const std::function<bool(TreeItem *)> &pred) const
@@ -859,7 +859,7 @@ TreeItem *TreeItem::findAnyChild(const std::function<bool(TreeItem *)> &pred) co
if (TreeItem *found = item->findAnyChild(pred))
return found;
}
return 0;
return nullptr;
}
TreeItem *TreeItem::reverseFindAnyChild(const std::function<bool (TreeItem *)> &pred) const
@@ -878,8 +878,8 @@ void TreeItem::clear()
{
while (childCount() != 0) {
TreeItem *item = m_children.takeLast();
item->m_model = 0;
item->m_parent = 0;
item->m_model = nullptr;
item->m_parent = nullptr;
delete item;
}
}
@@ -908,7 +908,7 @@ void TreeItem::collapse()
void TreeItem::propagateModel(BaseTreeModel *m)
{
QTC_ASSERT(m, return);
QTC_ASSERT(m_model == 0 || m_model == m, return);
QTC_ASSERT(m_model == nullptr || m_model == m, return);
if (m && !m_model) {
m_model = m;
for (TreeItem *item : *this)
@@ -945,9 +945,9 @@ BaseTreeModel::BaseTreeModel(TreeItem *root, QObject *parent)
BaseTreeModel::~BaseTreeModel()
{
QTC_ASSERT(m_root, return);
QTC_ASSERT(m_root->m_parent == 0, return);
QTC_ASSERT(m_root->m_parent == nullptr, return);
QTC_ASSERT(m_root->m_model == this, return);
m_root->m_model = 0;
m_root->m_model = nullptr;
delete m_root;
}
@@ -1039,7 +1039,7 @@ bool BaseTreeModel::hasChildren(const QModelIndex &idx) const
Qt::ItemFlags BaseTreeModel::flags(const QModelIndex &idx) const
{
if (!idx.isValid())
return 0;
return nullptr;
TreeItem *item = itemForIndex(idx);
return item ? item->flags(idx.column())
: (Qt::ItemIsEnabled|Qt::ItemIsSelectable);
@@ -1070,19 +1070,19 @@ TreeItem *BaseTreeModel::rootItem() const
void BaseTreeModel::setRootItem(TreeItem *item)
{
QTC_ASSERT(item, return);
QTC_ASSERT(item->m_model == 0, return);
QTC_ASSERT(item->m_parent == 0, return);
QTC_ASSERT(item->m_model == nullptr, return);
QTC_ASSERT(item->m_parent == nullptr, return);
QTC_ASSERT(item != m_root, return);
QTC_CHECK(m_root);
beginResetModel();
if (m_root) {
QTC_CHECK(m_root->m_parent == 0);
QTC_CHECK(m_root->m_parent == nullptr);
QTC_CHECK(m_root->m_model == this);
// needs to be done explicitly before setting the model to 0, otherwise it might lead to a
// crash inside a view or proxy model, especially if there are selected items
m_root->removeChildren();
m_root->m_model = 0;
m_root->m_model = nullptr;
delete m_root;
}
m_root = item;
@@ -1118,8 +1118,8 @@ TreeItem *BaseTreeModel::itemForIndex(const QModelIndex &idx) const
{
CHECK_INDEX(idx);
TreeItem *item = idx.isValid() ? static_cast<TreeItem*>(idx.internalPointer()) : m_root;
QTC_ASSERT(item, return 0);
QTC_ASSERT(item->m_model == static_cast<const BaseTreeModel *>(this), return 0);
QTC_ASSERT(item, return nullptr);
QTC_ASSERT(item->m_model == static_cast<const BaseTreeModel *>(this), return nullptr);
return item;
}
@@ -1132,7 +1132,7 @@ QModelIndex BaseTreeModel::indexForItem(const TreeItem *item) const
TreeItem *p = item->parent();
QTC_ASSERT(p, return QModelIndex());
TreeItem *mitem = const_cast<TreeItem *>(item);
auto mitem = const_cast<TreeItem *>(item);
int row = p->indexOf(mitem);
return createIndex(row, 0, mitem);
}
@@ -1166,8 +1166,8 @@ TreeItem *BaseTreeModel::takeItem(TreeItem *item)
QModelIndex idx = indexForItem(parent);
beginRemoveRows(idx, pos, pos);
item->m_parent = 0;
item->m_model = 0;
item->m_parent = nullptr;
item->m_model = nullptr;
parent->m_children.removeAt(pos);
endRemoveRows();
return item;

View File

@@ -135,7 +135,7 @@ void TreeViewComboBox::setCurrentIndex(const QModelIndex &index)
bool TreeViewComboBox::eventFilter(QObject *object, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress && object == view()->viewport()) {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
auto* mouseEvent = static_cast<QMouseEvent*>(event);
QModelIndex index = view()->indexAt(mouseEvent->pos());
if (!view()->visualRect(index).contains(mouseEvent->pos()))
m_skipNextHide = true;

View File

@@ -80,9 +80,9 @@ QTCREATOR_UTILS_EXPORT QString winGetDLLVersion(WinDLLVersionType t,
{
#ifdef Q_OS_WIN
// Resolve required symbols from the version.dll
typedef DWORD (APIENTRY *GetFileVersionInfoSizeProtoType)(LPCTSTR, LPDWORD);
typedef BOOL (APIENTRY *GetFileVersionInfoWProtoType)(LPCWSTR, DWORD, DWORD, LPVOID);
typedef BOOL (APIENTRY *VerQueryValueWProtoType)(const LPVOID, LPWSTR lpSubBlock, LPVOID, PUINT);
using GetFileVersionInfoSizeProtoType = DWORD (APIENTRY*)(LPCTSTR, LPDWORD);
using GetFileVersionInfoWProtoType = BOOL (APIENTRY*)(LPCWSTR, DWORD, DWORD, LPVOID);
using VerQueryValueWProtoType = BOOL (APIENTRY*)(const LPVOID, LPWSTR lpSubBlock, LPVOID, PUINT);
const char *versionDLLC = "version.dll";
QLibrary versionLib(QLatin1String(versionDLLC), 0);
@@ -91,9 +91,9 @@ QTCREATOR_UTILS_EXPORT QString winGetDLLVersion(WinDLLVersionType t,
return QString();
}
// MinGW requires old-style casts
GetFileVersionInfoSizeProtoType getFileVersionInfoSizeW = (GetFileVersionInfoSizeProtoType)(versionLib.resolve("GetFileVersionInfoSizeW"));
GetFileVersionInfoWProtoType getFileVersionInfoW = (GetFileVersionInfoWProtoType)(versionLib.resolve("GetFileVersionInfoW"));
VerQueryValueWProtoType verQueryValueW = (VerQueryValueWProtoType)(versionLib.resolve("VerQueryValueW"));
auto getFileVersionInfoSizeW = (GetFileVersionInfoSizeProtoType)(versionLib.resolve("GetFileVersionInfoSizeW"));
auto getFileVersionInfoW = (GetFileVersionInfoWProtoType)(versionLib.resolve("GetFileVersionInfoW"));
auto verQueryValueW = (VerQueryValueWProtoType)(versionLib.resolve("VerQueryValueW"));
if (!getFileVersionInfoSizeW || !getFileVersionInfoW || !verQueryValueW) {
*errorMessage = msgCannotResolve(versionDLLC);
return QString();
@@ -101,7 +101,7 @@ QTCREATOR_UTILS_EXPORT QString winGetDLLVersion(WinDLLVersionType t,
// Now go ahead, read version info resource
DWORD dummy = 0;
const LPCTSTR fileName = reinterpret_cast<LPCTSTR>(name.utf16()); // MinGWsy
const auto fileName = reinterpret_cast<LPCTSTR>(name.utf16()); // MinGWsy
const DWORD infoSize = (*getFileVersionInfoSizeW)(fileName, &dummy);
if (infoSize == 0) {
*errorMessage = QString::fromLatin1("Unable to determine the size of the version information of %1: %2").arg(name, winErrorMessage(GetLastError()));

View File

@@ -57,7 +57,7 @@ class ProgressItemWidget : public QWidget
{
Q_OBJECT
public:
ProgressItemWidget(const QPixmap &indicatorPixmap, const QString &title, QWidget *parent = 0)
ProgressItemWidget(const QPixmap &indicatorPixmap, const QString &title, QWidget *parent = nullptr)
: QWidget(parent),
m_indicatorVisible(false),
m_indicatorPixmap(indicatorPixmap)
@@ -65,7 +65,7 @@ public:
m_indicatorLabel = new QLabel(this);
m_indicatorLabel->setFixedSize(m_indicatorPixmap.size());
m_titleLabel = new QLabel(title, this);
QHBoxLayout *l = new QHBoxLayout(this);
auto l = new QHBoxLayout(this);
l->setMargin(0);
l->addWidget(m_indicatorLabel);
l->addWidget(m_titleLabel);
@@ -97,7 +97,7 @@ class LinearProgressWidget : public QWidget
{
Q_OBJECT
public:
LinearProgressWidget(WizardProgress *progress, QWidget *parent = 0);
LinearProgressWidget(WizardProgress *progress, QWidget *parent = nullptr);
private:
void slotItemAdded(WizardProgressItem *item);
@@ -126,14 +126,14 @@ private:
LinearProgressWidget::LinearProgressWidget(WizardProgress *progress, QWidget *parent)
:
QWidget(parent),
m_dotsItemWidget(0),
m_dotsItemWidget(nullptr),
m_disableUpdatesCount(0)
{
m_indicatorPixmap = QIcon::fromTheme(QLatin1String("go-next"), QIcon(QLatin1String(":/utils/images/arrow.png"))).pixmap(16);
m_wizardProgress = progress;
m_mainLayout = new QVBoxLayout(this);
m_itemWidgetLayout = new QVBoxLayout();
QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::Expanding);
auto spacer = new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::Expanding);
m_mainLayout->addLayout(m_itemWidgetLayout);
m_mainLayout->addSpacerItem(spacer);
@@ -477,7 +477,7 @@ void Wizard::_q_pageAdded(int pageId)
Q_D(Wizard);
QWizardPage *p = page(pageId);
WizardPage *wp = qobject_cast<WizardPage *>(p);
auto wp = qobject_cast<WizardPage *>(p);
if (wp)
wp->pageWasAdded();
@@ -501,8 +501,8 @@ void Wizard::_q_pageAdded(int pageId)
if (index < pages.count() - 1)
nextId = pages.at(index + 1);
WizardProgressItem *prevItem = 0;
WizardProgressItem *nextItem = 0;
WizardProgressItem *prevItem = nullptr;
WizardProgressItem *nextItem = nullptr;
if (prevId >= 0)
prevItem = d->m_wizardProgress->item(prevId);
@@ -538,8 +538,8 @@ void Wizard::_q_pageRemoved(int pageId)
if (index < pages.count() - 1)
nextId = pages.at(index + 1);
WizardProgressItem *prevItem = 0;
WizardProgressItem *nextItem = 0;
WizardProgressItem *prevItem = nullptr;
WizardProgressItem *nextItem = nullptr;
if (prevId >= 0)
prevItem = d->m_wizardProgress->item(prevId);
@@ -567,8 +567,8 @@ class WizardProgressPrivate
public:
WizardProgressPrivate()
:
m_currentItem(0),
m_startItem(0)
m_currentItem(nullptr),
m_startItem(nullptr)
{
}
@@ -673,7 +673,7 @@ QList<WizardProgressItem *> WizardProgressPrivate::singlePathBetween(WizardProgr
void WizardProgressPrivate::updateReachableItems()
{
m_reachableItems = m_visitedItems;
WizardProgressItem *item = 0;
WizardProgressItem *item = nullptr;
if (m_visitedItems.count() > 0)
item = m_visitedItems.last();
if (!item) {
@@ -712,7 +712,7 @@ WizardProgressItem *WizardProgress::addItem(const QString &title)
{
Q_D(WizardProgress);
WizardProgressItem *item = new WizardProgressItem(this, title);
auto item = new WizardProgressItem(this, title);
d->m_itemToItem.insert(item, item);
emit itemAdded(item);
return item;
@@ -835,7 +835,7 @@ void WizardProgress::setCurrentPage(int pageId)
Q_D(WizardProgress);
if (pageId < 0) { // reset history
d->m_currentItem = 0;
d->m_currentItem = nullptr;
d->m_visitedItems.clear();
d->m_reachableItems.clear();
d->updateReachableItems();
@@ -903,7 +903,7 @@ WizardProgressItem::WizardProgressItem(WizardProgress *progress, const QString &
d_ptr->m_title = title;
d_ptr->m_titleWordWrap = false;
d_ptr->m_wizardProgress = progress;
d_ptr->m_nextShownItem = 0;
d_ptr->m_nextShownItem = nullptr;
}
WizardProgressItem::~WizardProgressItem()
@@ -947,7 +947,7 @@ void WizardProgressItem::setNextItems(const QList<WizardProgressItem *> &items)
return;
if (!items.contains(d->m_nextShownItem))
setNextShownItem(0);
setNextShownItem(nullptr);
// update prev items (remove this item from the old next items)
for (int i = 0; i < d->m_nextItems.count(); i++) {

View File

@@ -43,7 +43,7 @@ WizardPage::WizardPage(QWidget *parent) : QWizardPage(parent)
void WizardPage::pageWasAdded()
{
Wizard *wiz = qobject_cast<Wizard *>(wizard());
auto wiz = qobject_cast<Wizard *>(wizard());
if (!wiz)
return;
@@ -62,7 +62,7 @@ void WizardPage::registerFieldWithName(const QString &name, QWidget *widget,
void WizardPage::registerFieldName(const QString &name)
{
Wizard *wiz = qobject_cast<Wizard *>(wizard());
auto wiz = qobject_cast<Wizard *>(wizard());
if (wiz)
wiz->registerFieldName(name);
else