Utils: More forward declarations / drop unused headers [T-Z]

Round 1 - focus on headers.
For classes with initial in range [T-Z].

Replace QT_FORWARD_DECLARE_CLASS with QT_BEGIN_NAMESPACE and
QT_END_NAMESPACE and forward declare inside.

Change-Id: I4ac3a8391e6167aa2db3973a9f94a45ac3c8ebd1
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2022-05-24 13:45:35 +02:00
parent d76eab7d2f
commit f3957d383f
44 changed files with 126 additions and 60 deletions

View File

@@ -30,7 +30,9 @@
#include <QString> #include <QString>
#include <QList> #include <QList>
QT_FORWARD_DECLARE_CLASS(QTextCursor) QT_BEGIN_NAMESPACE
class QTextCursor;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -29,7 +29,9 @@
#include <QAbstractButton> #include <QAbstractButton>
QT_FORWARD_DECLARE_CLASS(QGraphicsOpacityEffect) QT_BEGIN_NAMESPACE
class QGraphicsOpacityEffect;
QT_END_NAMESPACE
namespace Utils { namespace Utils {
class QTCREATOR_UTILS_EXPORT FadingPanel : public QWidget class QTCREATOR_UTILS_EXPORT FadingPanel : public QWidget

View File

@@ -34,7 +34,9 @@
#include <functional> #include <functional>
QT_FORWARD_DECLARE_CLASS(QProcessEnvironment) QT_BEGIN_NAMESPACE
class QProcessEnvironment;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -33,7 +33,9 @@
#include <QSharedPointer> #include <QSharedPointer>
#include <QStringList> #include <QStringList>
QT_FORWARD_DECLARE_CLASS(QUrl) QT_BEGIN_NAMESPACE
class QUrl;
QT_END_NAMESPACE
namespace Utils { namespace Utils {
class QrcParser; class QrcParser;

View File

@@ -29,7 +29,9 @@
#include "osspecificaspects.h" #include "osspecificaspects.h"
QT_FORWARD_DECLARE_CLASS(QString) QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#define QTC_HOST_EXE_SUFFIX QTC_WIN_EXE_SUFFIX #define QTC_HOST_EXE_SUFFIX QTC_WIN_EXE_SUFFIX

View File

@@ -27,7 +27,9 @@
#include "utils_global.h" #include "utils_global.h"
QT_FORWARD_DECLARE_CLASS(QString) QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -34,9 +34,11 @@
#include <QPair> #include <QPair>
#include <QVector> #include <QVector>
QT_FORWARD_DECLARE_CLASS(QColor) QT_BEGIN_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QPixmap) class QColor;
QT_FORWARD_DECLARE_CLASS(QString) class QPixmap;
class QString;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -32,7 +32,9 @@
#include <QStringList> #include <QStringList>
#include <QVector> #include <QVector>
QT_FORWARD_DECLARE_CLASS(QVariant) QT_BEGIN_NAMESPACE
class QVariant;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -34,7 +34,9 @@
#include <functional> #include <functional>
QT_FORWARD_DECLARE_CLASS(QAction) QT_BEGIN_NAMESPACE
class QAction;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -35,7 +35,9 @@
#include <functional> #include <functional>
#include <memory> #include <memory>
QT_FORWARD_DECLARE_CLASS(QPlainTextEdit) QT_BEGIN_NAMESPACE
class QPlainTextEdit;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -33,7 +33,9 @@
#include <QTimer> #include <QTimer>
#include <QValidator> #include <QValidator>
QT_FORWARD_DECLARE_CLASS(QModelIndex) QT_BEGIN_NAMESPACE
class QModelIndex;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -29,7 +29,9 @@
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
QT_FORWARD_DECLARE_CLASS(QUrl) QT_BEGIN_NAMESPACE
class QUrl;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -31,7 +31,9 @@
#include <functional> #include <functional>
QT_FORWARD_DECLARE_CLASS(QPushButton) QT_BEGIN_NAMESPACE
class QPushButton;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -29,7 +29,9 @@
#include "port.h" #include "port.h"
QT_FORWARD_DECLARE_CLASS(QString) QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE
namespace Utils { namespace Utils {
namespace Internal { class PortListPrivate; } namespace Internal { class PortListPrivate; }

View File

@@ -29,7 +29,9 @@
#include <QDialog> #include <QDialog>
QT_FORWARD_DECLARE_CLASS(QNetworkProxy) QT_BEGIN_NAMESPACE
class QNetworkProxy;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -29,7 +29,9 @@
#include <QFile> #include <QFile>
QT_FORWARD_DECLARE_CLASS(QTemporaryFile) QT_BEGIN_NAMESPACE
class QTemporaryFile;
QT_END_NAMESPACE
#include <memory> #include <memory>

View File

@@ -27,7 +27,9 @@
#include "utils_global.h" #include "utils_global.h"
QT_FORWARD_DECLARE_CLASS(QTimer) QT_BEGIN_NAMESPACE
class QTimer;
QT_END_NAMESPACE
#include <QLabel> #include <QLabel>

View File

@@ -25,6 +25,7 @@
#include "templateengine.h" #include "templateengine.h"
#include "macroexpander.h"
#include "qtcassert.h" #include "qtcassert.h"
#include <QJSEngine> #include <QJSEngine>

View File

@@ -27,14 +27,15 @@
#include "utils_global.h" #include "utils_global.h"
#include "macroexpander.h" QT_BEGIN_NAMESPACE
class QJSEngine;
#include <QString> class QString;
QT_END_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QJSEngine)
namespace Utils { namespace Utils {
class MacroExpander;
class QTCREATOR_UTILS_EXPORT TemplateEngine { class QTCREATOR_UTILS_EXPORT TemplateEngine {
public: public:
static bool preprocessText(const QString &input, QString *output, QString *errorMessage); static bool preprocessText(const QString &input, QString *output, QString *errorMessage);

View File

@@ -155,8 +155,8 @@ TerminalCommand TerminalCommand::terminalEmulator()
const QStringList splitCommand = ProcessArgs::splitArgs(value); const QStringList splitCommand = ProcessArgs::splitArgs(value);
if (QTC_GUARD(!splitCommand.isEmpty())) { if (QTC_GUARD(!splitCommand.isEmpty())) {
const QString command = splitCommand.first(); const QString command = splitCommand.first();
const QStringList quotedArgs = Utils::transform(splitCommand.mid(1), const QStringList quotedArgs = transform(splitCommand.mid(1),
&ProcessArgs::quoteArgUnix); &ProcessArgs::quoteArgUnix);
const QString options = quotedArgs.join(' '); const QString options = quotedArgs.join(' ');
return {command, "", options}; return {command, "", options};
} }

View File

@@ -437,14 +437,14 @@ void TerminalImpl::cleanupAfterStartFailure(const QString &errorMessage)
void TerminalImpl::sendControlSignal(ControlSignal controlSignal) void TerminalImpl::sendControlSignal(ControlSignal controlSignal)
{ {
switch (controlSignal) { switch (controlSignal) {
case Utils::ControlSignal::Terminate: case ControlSignal::Terminate:
case Utils::ControlSignal::Kill: case ControlSignal::Kill:
stopProcess(); stopProcess();
break; break;
case Utils::ControlSignal::Interrupt: case ControlSignal::Interrupt:
sendCommand('i'); sendCommand('i');
break; break;
case Utils::ControlSignal::KickOff: case ControlSignal::KickOff:
sendCommand('c'); sendCommand('c');
break; break;
} }

View File

@@ -32,11 +32,13 @@
namespace Utils { namespace Utils {
// Documentation inside. // Documentation inside.
class QTCREATOR_UTILS_EXPORT TextFieldCheckBox : public QCheckBox { class QTCREATOR_UTILS_EXPORT TextFieldCheckBox : public QCheckBox
{
Q_PROPERTY(QString compareText READ text WRITE setText) Q_PROPERTY(QString compareText READ text WRITE setText)
Q_PROPERTY(QString trueText READ trueText WRITE setTrueText) Q_PROPERTY(QString trueText READ trueText WRITE setTrueText)
Q_PROPERTY(QString falseText READ falseText WRITE setFalseText) Q_PROPERTY(QString falseText READ falseText WRITE setFalseText)
Q_OBJECT Q_OBJECT
public: public:
explicit TextFieldCheckBox(const QString &text, QWidget *parent = nullptr); explicit TextFieldCheckBox(const QString &text, QWidget *parent = nullptr);

View File

@@ -32,9 +32,11 @@
namespace Utils { namespace Utils {
// Documentation inside. // Documentation inside.
class QTCREATOR_UTILS_EXPORT TextFieldComboBox : public QComboBox { class QTCREATOR_UTILS_EXPORT TextFieldComboBox : public QComboBox
{
Q_PROPERTY(QString indexText READ text WRITE setText) Q_PROPERTY(QString indexText READ text WRITE setText)
Q_OBJECT Q_OBJECT
public: public:
explicit TextFieldComboBox(QWidget *parent = nullptr); explicit TextFieldComboBox(QWidget *parent = nullptr);

View File

@@ -165,7 +165,7 @@ int utf8NthLineOffset(const QTextDocument *textDocument, const QByteArray &buffe
LineColumn utf16LineColumn(const QByteArray &utf8Buffer, int utf8Offset) LineColumn utf16LineColumn(const QByteArray &utf8Buffer, int utf8Offset)
{ {
Utils::LineColumn lineColumn; LineColumn lineColumn;
lineColumn.line = static_cast<int>( lineColumn.line = static_cast<int>(
std::count(utf8Buffer.begin(), utf8Buffer.begin() + utf8Offset, '\n')) std::count(utf8Buffer.begin(), utf8Buffer.begin() + utf8Offset, '\n'))
+ 1; + 1;
@@ -221,7 +221,7 @@ void applyReplacements(QTextDocument *doc, const Replacements &replacements)
int fullOffsetShift = 0; int fullOffsetShift = 0;
QTextCursor editCursor(doc); QTextCursor editCursor(doc);
editCursor.beginEditBlock(); editCursor.beginEditBlock();
for (const Utils::Text::Replacement &replacement : replacements) { for (const Text::Replacement &replacement : replacements) {
editCursor.setPosition(replacement.offset + fullOffsetShift); editCursor.setPosition(replacement.offset + fullOffsetShift);
editCursor.movePosition(QTextCursor::NextCharacter, editCursor.movePosition(QTextCursor::NextCharacter,
QTextCursor::KeepAnchor, QTextCursor::KeepAnchor,

View File

@@ -25,13 +25,16 @@
#pragma once #pragma once
#include "linecolumn.h"
#include "utils_global.h" #include "utils_global.h"
#include "linecolumn.h"
#include <QString> #include <QString>
QT_FORWARD_DECLARE_CLASS(QTextDocument) QT_BEGIN_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QTextCursor) class QTextCursor;
class QTextDocument;
QT_END_NAMESPACE
namespace Utils { namespace Utils {
namespace Text { namespace Text {

View File

@@ -30,8 +30,10 @@
#include <QBrush> // QGradientStops #include <QBrush> // QGradientStops
#include <QObject> #include <QObject>
QT_FORWARD_DECLARE_CLASS(QSettings) QT_BEGIN_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QPalette) class QPalette;
class QSettings;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -25,9 +25,10 @@
#pragma once #pragma once
#include "theme.h"
#include "../utils_global.h" #include "../utils_global.h"
#include "theme.h"
#include <QColor> #include <QColor>
#include <QMap> #include <QMap>

View File

@@ -26,12 +26,11 @@
#include "tips.h" #include "tips.h"
#include "tooltip.h" #include "tooltip.h"
#include <utils/hostosinfo.h> #include "../qtcassert.h"
#include <utils/qtcassert.h>
#include <QApplication>
#include <QColor> #include <QColor>
#include <QFontMetrics> #include <QFontMetrics>
#include <QGuiApplication>
#include <QPaintEvent> #include <QPaintEvent>
#include <QPainter> #include <QPainter>
#include <QPen> #include <QPen>
@@ -43,6 +42,7 @@
#include <QStyleOptionFrame> #include <QStyleOptionFrame>
#include <QTextDocument> #include <QTextDocument>
#include <QScreen> #include <QScreen>
#include <QVBoxLayout>
#include <QWidget> #include <QWidget>
#include <memory> #include <memory>

View File

@@ -29,9 +29,11 @@
#include <QLabel> #include <QLabel>
#include <QPixmap> #include <QPixmap>
#include <QSharedPointer>
#include <QVariant> #include <QVariant>
#include <QVBoxLayout>
QT_BEGIN_NAMESPACE
class QVBoxLayout;
QT_END_NAMESPACE
namespace Utils { namespace Utils {
namespace Internal { namespace Internal {

View File

@@ -27,7 +27,6 @@
#include "../utils_global.h" #include "../utils_global.h"
#include <QSharedPointer>
#include <QObject> #include <QObject>
#include <QPointer> #include <QPointer>
#include <QTimer> #include <QTimer>

View File

@@ -25,6 +25,11 @@
#include "touchbar.h" #include "touchbar.h"
#include <QAction>
#include <QByteArray>
#include <QIcon>
#include <QString>
namespace Utils { namespace Utils {
namespace Internal { namespace Internal {

View File

@@ -25,12 +25,14 @@
#pragma once #pragma once
#include <utils/utils_global.h> #include "../utils_global.h"
#include <QAction> QT_BEGIN_NAMESPACE
#include <QByteArray> class QAction;
#include <QIcon> class QByteArray;
#include <QString> class QIcon;
class QString;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -26,6 +26,7 @@
#pragma once #pragma once
#include "utils_global.h" #include "utils_global.h"
#include "indexedcontainerproxyconstiterator.h" #include "indexedcontainerproxyconstiterator.h"
#include <QAbstractItemModel> #include <QAbstractItemModel>

View File

@@ -29,6 +29,7 @@
#include "utils/multitextcursor.h" #include "utils/multitextcursor.h"
#include <QTextBlock> #include <QTextBlock>
#include <QTextCursor>
#include <QTextDocument> #include <QTextDocument>
namespace Utils { namespace Utils {

View File

@@ -28,10 +28,10 @@
#include "utils_global.h" #include "utils_global.h"
#include <QString> #include <QString>
#include <QTextCursor>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QPlainTextEdit; class QPlainTextEdit;
class QTextCursor;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -29,6 +29,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QSettings; class QSettings;
class QString;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -28,6 +28,7 @@
#include <QHostAddress> #include <QHostAddress>
#include <QTcpServer> #include <QTcpServer>
#include <QUrl>
namespace Utils { namespace Utils {

View File

@@ -26,7 +26,11 @@
#pragma once #pragma once
#include "utils_global.h" #include "utils_global.h"
#include <QUrl>
QT_BEGIN_NAMESPACE
class QString;
class QUrl;
QT_END_NAMESPACE
namespace Utils { namespace Utils {

View File

@@ -104,7 +104,7 @@ public:
void createIconButton() void createIconButton()
{ {
m_iconButton = new IconButton; m_iconButton = new IconButton;
m_iconButton->setIcon(Utils::Icons::REPLACE.icon()); m_iconButton->setIcon(Icons::REPLACE.icon());
m_iconButton->setToolTip(VariableChooser::tr("Insert Variable")); m_iconButton->setToolTip(VariableChooser::tr("Insert Variable"));
m_iconButton->hide(); m_iconButton->hide();
connect(m_iconButton.data(), static_cast<void(QAbstractButton::*)(bool)>(&QAbstractButton::clicked), connect(m_iconButton.data(), static_cast<void(QAbstractButton::*)(bool)>(&QAbstractButton::clicked),
@@ -132,7 +132,7 @@ public:
QPointer<QPlainTextEdit> m_plainTextEdit; QPointer<QPlainTextEdit> m_plainTextEdit;
QPointer<IconButton> m_iconButton; QPointer<IconButton> m_iconButton;
Utils::FancyLineEdit *m_variableFilter; FancyLineEdit *m_variableFilter;
VariableTreeView *m_variableTree; VariableTreeView *m_variableTree;
QLabel *m_variableDescription; QLabel *m_variableDescription;
QSortFilterProxyModel *m_sortModel; QSortFilterProxyModel *m_sortModel;
@@ -275,7 +275,7 @@ VariableChooserPrivate::VariableChooserPrivate(VariableChooser *parent)
{ {
m_defaultDescription = VariableChooser::tr("Select a variable to insert."); m_defaultDescription = VariableChooser::tr("Select a variable to insert.");
m_variableFilter = new Utils::FancyLineEdit(q); m_variableFilter = new FancyLineEdit(q);
m_variableTree = new VariableTreeView(q, this); m_variableTree = new VariableTreeView(q, this);
m_variableDescription = new QLabel(q); m_variableDescription = new QLabel(q);

View File

@@ -26,7 +26,6 @@
#pragma once #pragma once
#include "utils_global.h" #include "utils_global.h"
#include "macroexpander.h"
#include <QWidget> #include <QWidget>
@@ -34,6 +33,8 @@
namespace Utils { namespace Utils {
class MacroExpander;
namespace Internal { class VariableChooserPrivate; } namespace Internal { class VariableChooserPrivate; }
class QTCREATOR_UTILS_EXPORT VariableChooser : public QWidget class QTCREATOR_UTILS_EXPORT VariableChooser : public QWidget
@@ -44,10 +45,10 @@ public:
explicit VariableChooser(QWidget *parent = nullptr); explicit VariableChooser(QWidget *parent = nullptr);
~VariableChooser() override; ~VariableChooser() override;
void addMacroExpanderProvider(const Utils::MacroExpanderProvider &provider); void addMacroExpanderProvider(const std::function<MacroExpander *()> &provider);
void addSupportedWidget(QWidget *textcontrol, const QByteArray &ownName = QByteArray()); void addSupportedWidget(QWidget *textcontrol, const QByteArray &ownName = QByteArray());
static void addSupportForChildWidgets(QWidget *parent, Utils::MacroExpander *expander); static void addSupportForChildWidgets(QWidget *parent, MacroExpander *expander);
protected: protected:
bool event(QEvent *ev) override; bool event(QEvent *ev) override;

View File

@@ -319,7 +319,7 @@ Wizard::Wizard(QWidget *parent, Qt::WindowFlags flags) :
setOption(QWizard::NoCancelButton, false); setOption(QWizard::NoCancelButton, false);
setOption(QWizard::NoDefaultButton, false); setOption(QWizard::NoDefaultButton, false);
setOption(QWizard::NoBackButtonOnStartPage, true); setOption(QWizard::NoBackButtonOnStartPage, true);
if (!Utils::creatorTheme()->preferredStyles().isEmpty()) if (!creatorTheme()->preferredStyles().isEmpty())
setWizardStyle(QWizard::ModernStyle); setWizardStyle(QWizard::ModernStyle);
if (HostOsInfo::isMacHost()) { if (HostOsInfo::isMacHost()) {

View File

@@ -44,6 +44,7 @@
#include <utils/delegates.h> #include <utils/delegates.h>
#include <utils/fancylineedit.h> #include <utils/fancylineedit.h>
#include <utils/jsontreeitem.h> #include <utils/jsontreeitem.h>
#include <utils/macroexpander.h>
#include <utils/stringutils.h> #include <utils/stringutils.h>
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
#include <utils/variablechooser.h> #include <utils/variablechooser.h>

View File

@@ -26,6 +26,7 @@
#include "snippet.h" #include "snippet.h"
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/macroexpander.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/templateengine.h> #include <utils/templateengine.h>

View File

@@ -23,6 +23,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include <utils/macroexpander.h>
#include <utils/templateengine.h> #include <utils/templateengine.h>
#include <QtTest> #include <QtTest>