Todo: Modernize

modernize-*

Change-Id: Ib03e15cac77fa15d51f18e3351462a0c5a9ab224
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Alessandro Portale
2018-12-10 00:19:56 +01:00
parent d137b33a42
commit 7ea23f24fb
23 changed files with 68 additions and 80 deletions

View File

@@ -36,10 +36,10 @@ namespace Internal {
class CppTodoItemsScanner : public TodoItemsScanner
{
public:
explicit CppTodoItemsScanner(const KeywordList &keywordList, QObject *parent = 0);
explicit CppTodoItemsScanner(const KeywordList &keywordList, QObject *parent = nullptr);
protected:
void scannerParamsChanged();
void scannerParamsChanged() override;
private:
void documentUpdated(CPlusPlus::Document::Ptr doc);

View File

@@ -47,7 +47,7 @@ public:
bool equals(const Keyword &other) const;
};
typedef QList<Keyword> KeywordList;
using KeywordList = QList<Keyword>;
bool operator ==(Keyword &k1, Keyword &k2);
bool operator !=(Keyword &k1, Keyword &k2);

View File

@@ -142,8 +142,8 @@ bool KeywordDialog::isKeywordNameCorrect()
if (name.isEmpty())
return false;
for (int i = 0; i < name.size(); ++i)
if (LineParser::isKeywordSeparator(name.at(i)))
for (const QChar i : name)
if (LineParser::isKeywordSeparator(i))
return false;
return true;

View File

@@ -42,8 +42,8 @@ class KeywordDialog : public QDialog
Q_OBJECT
public:
KeywordDialog(const Keyword &keyword, const QSet<QString> &alreadyUsedKeywordNames,
QWidget *parent = 0);
~KeywordDialog();
QWidget *parent = nullptr);
~KeywordDialog() override;
Keyword keyword();

View File

@@ -47,7 +47,7 @@ private:
// map key here is keyword start position in the text line
// and map value is keyword index in m_keywords
typedef QMap<int, int> KeywordEntryCandidates;
using KeywordEntryCandidates = QMap<int, int> ;
struct KeywordEntry {
int keywordIndex;

View File

@@ -43,8 +43,8 @@ class Keyword;
class OptionsDialog : public QWidget
{
public:
explicit OptionsDialog(QWidget *parent = 0);
~OptionsDialog();
explicit OptionsDialog(QWidget *parent = nullptr);
~OptionsDialog() override;
void setSettings(const Settings &settings);
Settings settings();

View File

@@ -34,14 +34,13 @@
#include <QIcon>
#include <QMessageBox>
Todo::Internal::OptionsDialog *some = 0;
Todo::Internal::OptionsDialog *some = nullptr;
namespace Todo {
namespace Internal {
OptionsPage::OptionsPage(const Settings &settings, QObject *parent) :
IOptionsPage(parent),
m_widget(0)
IOptionsPage(parent)
{
setSettings(settings);

View File

@@ -42,13 +42,13 @@ class OptionsPage : public Core::IOptionsPage
Q_OBJECT
public:
OptionsPage(const Settings &settings, QObject *parent = 0);
OptionsPage(const Settings &settings, QObject *parent = nullptr);
void setSettings(const Settings &settings);
QWidget *widget();
void apply();
void finish();
QWidget *widget() override;
void apply() override;
void finish() override;
signals:
void settingsChanged(const Settings &settings);

View File

@@ -36,7 +36,7 @@ namespace Internal {
class QmlJsTodoItemsScanner : public TodoItemsScanner
{
public:
explicit QmlJsTodoItemsScanner(const KeywordList &keywordList, QObject *parent = 0);
explicit QmlJsTodoItemsScanner(const KeywordList &keywordList, QObject *parent = nullptr);
protected:
bool shouldProcessFile(const QString &fileName);

View File

@@ -41,12 +41,10 @@ namespace Internal {
class TodoItem
{
public:
TodoItem() : line(-1) {}
QString text;
Utils::FileName file;
int line;
IconType iconType;
int line = -1;
IconType iconType = IconType::Todo;
QColor color;
};

View File

@@ -40,9 +40,7 @@ namespace Internal {
TodoItemsModel::TodoItemsModel(QObject *parent) :
QAbstractTableModel(parent),
m_todoItemsList(0),
m_currentSortColumn(Constants::OutputColumnIndex(0)),
m_currentSortOrder(Qt::AscendingOrder)
m_currentSortColumn(Constants::OutputColumnIndex(0))
{
}

View File

@@ -39,22 +39,22 @@ class TodoItemsModel : public QAbstractTableModel
Q_OBJECT
public:
explicit TodoItemsModel(QObject *parent = 0);
explicit TodoItemsModel(QObject *parent = nullptr);
void setTodoItemsList(QList<TodoItem> *list);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
void todoItemsListUpdated();
private:
QList<TodoItem> *m_todoItemsList;
QList<TodoItem> *m_todoItemsList = nullptr;
Constants::OutputColumnIndex m_currentSortColumn;
Qt::SortOrder m_currentSortOrder;
Qt::SortOrder m_currentSortOrder = Qt::AscendingOrder;
};
}

View File

@@ -46,7 +46,7 @@ class TodoItemsProvider : public QObject
Q_OBJECT
public:
explicit TodoItemsProvider(Settings settings, QObject *parent = 0);
explicit TodoItemsProvider(Settings settings, QObject *parent = nullptr);
TodoItemsModel *todoItemsModel();
void settingsChanged(const Settings &newSettings);

View File

@@ -41,7 +41,7 @@ class TodoItemsScanner : public QObject
Q_OBJECT
public:
explicit TodoItemsScanner(const KeywordList &keywordList, QObject *parent = 0);
explicit TodoItemsScanner(const KeywordList &keywordList, QObject *parent = nullptr);
void setParams(const KeywordList &keywordList);
signals:

View File

@@ -193,7 +193,7 @@ void TodoOutputPane::updateTodoCount()
void TodoOutputPane::updateFilter()
{
QStringList keywords;
for (QToolButton *btn: m_filterButtons) {
for (const QToolButton *btn: qAsConst(m_filterButtons)) {
if (btn->isChecked())
keywords.append(btn->property(Constants::FILTER_KEYWORD_NAME).toString());
}
@@ -210,7 +210,7 @@ void TodoOutputPane::updateFilter()
void TodoOutputPane::clearFilter()
{
for (QToolButton *btn: m_filterButtons)
for (QToolButton *btn: qAsConst(m_filterButtons))
btn->setChecked(false);
updateFilter();
@@ -225,7 +225,7 @@ void TodoOutputPane::createTreeView()
m_todoTreeView = new TodoOutputTreeView();
m_todoTreeView->setModel(m_filteredTodoItemsModel);
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
auto agg = new Aggregation::Aggregate;
agg->add(m_todoTreeView);
agg->add(new Core::ItemViewFind(m_todoTreeView));
@@ -240,7 +240,7 @@ void TodoOutputPane::freeTreeView()
QToolButton *TodoOutputPane::createCheckableToolButton(const QString &text, const QString &toolTip, const QIcon &icon)
{
QToolButton *button = new QToolButton();
auto button = new QToolButton;
button->setCheckable(true);
button->setText(text);

View File

@@ -45,30 +45,30 @@ class TodoItem;
class TodoItemsModel;
class TodoOutputTreeView;
typedef QList<QToolButton*> QToolButtonList;
using QToolButtonList = QList<QToolButton *>;
class TodoOutputPane : public Core::IOutputPane
{
Q_OBJECT
public:
TodoOutputPane(TodoItemsModel *todoItemsModel, const Settings *settings, QObject *parent = 0);
~TodoOutputPane();
TodoOutputPane(TodoItemsModel *todoItemsModel, const Settings *settings, QObject *parent = nullptr);
~TodoOutputPane() override;
QWidget *outputWidget(QWidget *parent);
QList<QWidget*> toolBarWidgets() const;
QString displayName() const;
int priorityInStatusBar() const;
void clearContents();
void visibilityChanged(bool visible);
void setFocus();
bool hasFocus() const;
bool canFocus() const;
bool canNavigate() const;
bool canNext() const;
bool canPrevious() const;
void goToNext();
void goToPrev();
QWidget *outputWidget(QWidget *parent) override;
QList<QWidget*> toolBarWidgets() const override;
QString displayName() const override;
int priorityInStatusBar() const override;
void clearContents() override;
void visibilityChanged(bool visible) override;
void setFocus() override;
bool hasFocus() const override;
bool canFocus() const override;
bool canNavigate() const override;
bool canNext() const override;
bool canPrevious() const override;
void goToNext() override;
void goToPrev() override;
void setScanningScope(ScanningScope scanningScope);

View File

@@ -37,9 +37,7 @@ namespace Todo {
namespace Internal {
TodoOutputTreeView::TodoOutputTreeView(QWidget *parent) :
Utils::TreeView(parent),
m_textColumnDefaultWidth(0),
m_fileColumnDefaultWidth(0)
Utils::TreeView(parent)
{
setRootIsDecorated(false);
setFrameStyle(QFrame::NoFrame);

View File

@@ -33,10 +33,10 @@ namespace Internal {
class TodoOutputTreeView : public Utils::TreeView
{
public:
explicit TodoOutputTreeView(QWidget *parent = 0);
~TodoOutputTreeView();
explicit TodoOutputTreeView(QWidget *parent = nullptr);
~TodoOutputTreeView() override;
void resizeEvent(QResizeEvent *event);
void resizeEvent(QResizeEvent *event) override;
private:
void todoColumnResized(int column, int oldSize, int newSize);
@@ -44,8 +44,8 @@ private:
void saveDisplaySettings();
void loadDisplaySettings();
qreal m_textColumnDefaultWidth;
qreal m_fileColumnDefaultWidth;
qreal m_textColumnDefaultWidth = 0.0;
qreal m_fileColumnDefaultWidth = 0.0;
};
} // namespace Internal

View File

@@ -34,7 +34,7 @@ class TodoOutputTreeViewDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit TodoOutputTreeViewDelegate(QObject *parent = 0);
explicit TodoOutputTreeViewDelegate(QObject *parent = nullptr);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
};

View File

@@ -45,17 +45,12 @@
namespace Todo {
namespace Internal {
TodoPlugin::TodoPlugin() :
m_todoOutputPane(0),
m_optionsPage(0),
m_todoItemsProvider(0)
TodoPlugin::TodoPlugin()
{
qRegisterMetaType<TodoItem>("TodoItem");
}
TodoPlugin::~TodoPlugin()
{
}
TodoPlugin::~TodoPlugin() = default;
bool TodoPlugin::initialize(const QStringList& args, QString *errMsg)
{

View File

@@ -45,10 +45,10 @@ class TodoPlugin : public ExtensionSystem::IPlugin
public:
TodoPlugin();
~TodoPlugin();
~TodoPlugin() override;
void extensionsInitialized();
bool initialize(const QStringList &arguments, QString *errorString);
void extensionsInitialized() override;
bool initialize(const QStringList &arguments, QString *errorString) override;
private:
void settingsChanged(const Settings &settings);
@@ -59,9 +59,9 @@ private:
void createOptionsPage();
Settings m_settings;
TodoOutputPane *m_todoOutputPane;
OptionsPage *m_optionsPage;
TodoItemsProvider *m_todoItemsProvider;
TodoOutputPane *m_todoOutputPane = nullptr;
OptionsPage *m_optionsPage = nullptr;
TodoItemsProvider *m_todoItemsProvider = nullptr;
};
} // namespace Internal

View File

@@ -63,7 +63,7 @@ TodoProjectSettingsWidget::~TodoProjectSettingsWidget()
QListWidgetItem *TodoProjectSettingsWidget::addToExcludedPatternsList(const QString &pattern)
{
QListWidgetItem *item = new QListWidgetItem(pattern);
auto item = new QListWidgetItem(pattern);
item->setFlags(item->flags() | Qt::ItemIsEditable);
prepareItem(item);
ui->excludedPatternsList->addItem(item);

View File

@@ -48,7 +48,7 @@ class TodoProjectSettingsWidget : public QWidget
public:
explicit TodoProjectSettingsWidget(ProjectExplorer::Project *project);
~TodoProjectSettingsWidget();
~TodoProjectSettingsWidget() override;
signals:
void projectSettingsChanged();