diff --git a/commanditemmodel.cpp b/commanditemmodel.cpp index 9d07e2a..1ac7397 100644 --- a/commanditemmodel.cpp +++ b/commanditemmodel.cpp @@ -104,14 +104,11 @@ bool CommandItemModel::filterAcceptsRow(int sourceRow, const QModelIndex &source const CommandProviderItem *item = mSourceModel->command(sourceRow); - if (!item) - return false; - - bool accept = item->compare(re); + bool accept = item != nullptr && item->compare(re); if (accept) { //check if CustomCommand can be filtered out (equivalent app link is shown) - const CustomCommandItem * cust_i = qobject_cast(item); + auto cust_i = qobject_cast(item); if (nullptr != cust_i) { for (int i = mSourceModel->rowCount(sourceParent); 0 <= i; --i) @@ -144,8 +141,8 @@ bool CommandItemModel::lessThan(const QModelIndex &left, const QModelIndex &righ const auto leftItem = mSourceModel->command(left); const auto righItem = mSourceModel->command(right); - HistoryItem const * i_left = dynamic_cast(leftItem); - HistoryItem const * i_right = dynamic_cast(righItem); + auto i_left = qobject_cast(leftItem); + auto i_right = qobject_cast(righItem); if (nullptr != i_left && nullptr == i_right) return mShowHistoryFirst; if (nullptr == i_left && nullptr != i_right) @@ -154,8 +151,8 @@ bool CommandItemModel::lessThan(const QModelIndex &left, const QModelIndex &righ { QRegExp re(filterRegExp()); //Note: -1 should not be returned if the item passed the filter previously - const int pos_left = re.indexIn(i_left->command()); - const int pos_right = re.indexIn(i_right->command()); + int pos_left = re.indexIn(i_left->command()); + int pos_right = re.indexIn(i_right->command()); Q_ASSERT(-1 != pos_left && -1 != pos_right); return pos_left < pos_right || (pos_left == pos_right && QSortFilterProxyModel::lessThan(left, right)); @@ -180,10 +177,9 @@ int CommandItemModel::itemType(const QModelIndex &index) const { if (index.row() == mSourceModel->customCommandIndex().row()) return 1; - else if (index.row() < mSourceModel->externalProviderStartIndex().row()) + if (index.row() < mSourceModel->externalProviderStartIndex().row()) return 2; - else - return 3; + return 3; } @@ -331,7 +327,7 @@ QVariant CommandSourceItemModel::data(const QModelIndex &index, int role) const if (index.row() >= rowCount()) return QVariant(); - const CommandProviderItem *item = command(index); + auto item = command(index); if (!item) return QVariant(); diff --git a/commanditemmodel.h b/commanditemmodel.h index 796bea5..e21e59d 100644 --- a/commanditemmodel.h +++ b/commanditemmodel.h @@ -41,10 +41,10 @@ class CommandSourceItemModel: public QAbstractListModel public: explicit CommandSourceItemModel(bool useHistory, QObject *parent = 0); - virtual ~CommandSourceItemModel(); + ~CommandSourceItemModel() override; - int rowCount(const QModelIndex &parent=QModelIndex()) const; - QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const; + int rowCount(const QModelIndex &parent=QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override; bool isOutDated() const; const CommandProviderItem *command(const QModelIndex &index) const; @@ -80,7 +80,7 @@ class CommandItemModel: public QSortFilterProxyModel public: explicit CommandItemModel(bool useHistory, QObject *parent = 0); - virtual ~CommandItemModel(); + ~CommandItemModel() override; bool isOutDated() const; const CommandProviderItem *command(const QModelIndex &index) const; @@ -104,8 +104,8 @@ public slots: void clearHistory(); protected: - bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; - bool lessThan(const QModelIndex &left, const QModelIndex &right) const; + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; + bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; private: int itemType(const QModelIndex &index) const; diff --git a/mylistview.h b/mylistview.h index 9a55937..473397b 100644 --- a/mylistview.h +++ b/mylistview.h @@ -42,7 +42,7 @@ class MyListView : public QListView } protected: - virtual QSize viewportSizeHint() const override + QSize viewportSizeHint() const override { QAbstractItemModel * m = model(); if (m == nullptr) diff --git a/providers.h b/providers.h index afa02c9..96e60da 100644 --- a/providers.h +++ b/providers.h @@ -51,7 +51,6 @@ class CommandProviderItem: public QObject public: CommandProviderItem(): QObject() {} - virtual ~CommandProviderItem() {} virtual bool run() const = 0; virtual bool compare(const QRegExp ®Exp) const = 0; @@ -95,7 +94,7 @@ class CommandProvider: public QObject, public QList public: CommandProvider(); - virtual ~CommandProvider(); + ~CommandProvider() override; virtual void rebuild() {} virtual bool isOutDated() const { return false; } @@ -149,7 +148,7 @@ class AppLinkProvider: public CommandProvider public: AppLinkProvider(); - virtual ~AppLinkProvider(); + ~AppLinkProvider() override; private slots: void update(); @@ -195,7 +194,7 @@ class HistoryProvider: public CommandProvider public: HistoryProvider(); - virtual ~HistoryProvider(); + ~HistoryProvider() override; void AddCommand(const QString &command); void clearHistory(); @@ -218,14 +217,14 @@ class CustomCommandItem: public CommandProviderItem public: CustomCommandItem(CustomCommandProvider *provider); - bool run() const; - bool compare(const QRegExp ®Exp) const; + bool run() const override; + bool compare(const QRegExp ®Exp) const override; QString command() const { return mCommand; } void setCommand(const QString &command); QString exec() const { return mExec; } - virtual unsigned int rank(const QString &pattern) const; + unsigned int rank(const QString &pattern) const override; private: QString mCommand; QString mExec; //!< the expanded executable (full path) @@ -269,9 +268,9 @@ class MathItem: public CommandProviderItem MathItem(); ~MathItem(); - bool run() const; - bool compare(const QRegExp ®Exp) const; - virtual unsigned int rank(const QString &pattern) const; + bool run() const override; + bool compare(const QRegExp ®Exp) const override; + unsigned int rank(const QString &pattern) const override; private: QScopedPointer mParser; mutable QString mCachedInput; @@ -285,7 +284,7 @@ class MathProvider: public CommandProvider public: MathProvider(); - //virtual ~MathProvider(); + //~MathProvider() override; }; #endif @@ -303,9 +302,9 @@ class VirtualBoxItem: public CommandProviderItem VirtualBoxItem(const QString & MachineName , const QIcon & Icon); void setRDEPort (const QString & portNum); - bool run() const; - bool compare(const QRegExp ®Exp) const; - virtual unsigned int rank(const QString &pattern) const; + bool run() const override; + bool compare(const QRegExp ®Exp) const override; + unsigned int rank(const QString &pattern) const override; private: QString m_rdePortNum; }; diff --git a/yamlparser.cpp b/yamlparser.cpp index cf7c04a..b82e997 100644 --- a/yamlparser.cpp +++ b/yamlparser.cpp @@ -38,10 +38,6 @@ YamlParser::YamlParser() state = start; } -YamlParser::~YamlParser() -{ -} - void YamlParser::consumeLine(QString line) { static QRegExp documentStart(QSL("---\\s*(\\[\\]\\s*)?")); diff --git a/yamlparser.h b/yamlparser.h index ca9d2a9..6dedf09 100644 --- a/yamlparser.h +++ b/yamlparser.h @@ -40,7 +40,6 @@ class YamlParser : public QObject Q_OBJECT public: YamlParser(); - virtual ~YamlParser(); void consumeLine(QString line);