X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fflatproxymodel.h;h=84fb77972728301d754ec15a77563739c6985864;hp=e0c5f5b5034f798d22134d547d682ccc7743b6c1;hb=158443f71d48215eea8b47b836b61afd77654b78;hpb=9d54503555534a2c554f09a33df6afa33d6308ec diff --git a/src/uisupport/flatproxymodel.h b/src/uisupport/flatproxymodel.h index e0c5f5b5..84fb7797 100644 --- a/src/uisupport/flatproxymodel.h +++ b/src/uisupport/flatproxymodel.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2014 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,31 +18,32 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef FLATPROXYMODEL_H -#define FLATPROXYMODEL_H +#pragma once + +#include "uisupport-export.h" #include -class FlatProxyModel : public QAbstractProxyModel +class UISUPPORT_EXPORT FlatProxyModel : public QAbstractProxyModel { Q_OBJECT public: - FlatProxyModel(QObject *parent = 0); + FlatProxyModel(QObject *parent = nullptr); - virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; - virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const; + QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override; + QModelIndex mapToSource(const QModelIndex &proxyIndex) const override; - virtual QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const; - virtual QItemSelection mapSelectionToSource(const QItemSelection &proxySelection) const; + QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const override; + QItemSelection mapSelectionToSource(const QItemSelection &proxySelection) const override; - virtual void setSourceModel(QAbstractItemModel *sourceModel); + void setSourceModel(QAbstractItemModel *sourceModel) override; - virtual QModelIndex index(int row, int column, const QModelIndex &parent) const; - virtual QModelIndex parent(const QModelIndex &index) const; + QModelIndex index(int row, int column, const QModelIndex &parent) const override; + QModelIndex parent(const QModelIndex &index) const override; - virtual int rowCount(const QModelIndex &index) const; - virtual int columnCount(const QModelIndex &index) const; + int rowCount(const QModelIndex &index) const override; + int columnCount(const QModelIndex &index) const override; public slots: void linkTest() const; @@ -60,7 +61,7 @@ private slots: void on_layoutAboutToBeChanged(); void on_layoutChanged(); - inline void on_modelAboutToBeReset() { reset(); } + inline void on_modelAboutToBeReset() { beginResetModel(); endResetModel(); } // void on_modelReset(); void on_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end); @@ -72,7 +73,7 @@ private: QList _childCount; class SourceItem; - SourceItem *_rootSourceItem; + SourceItem *_rootSourceItem{nullptr}; void insertSubTree(const QModelIndex &source_idx, bool emitInsert = true); SourceItem *insertSubTreeHelper(SourceItem *parentItem, SourceItem *lastItem_, const QModelIndex &source_idx); @@ -96,7 +97,7 @@ public: class FlatProxyModel::SourceItem { public: - SourceItem(int row = 0, SourceItem *parent = 0); + SourceItem(int row = 0, SourceItem *parent = nullptr); ~SourceItem(); inline SourceItem *parent() const { return _parent; } @@ -116,11 +117,8 @@ private: SourceItem *_parent; QList _childs; - int _pos; - SourceItem *_next; + int _pos{-1}; + SourceItem *_next{nullptr}; friend class FlatProxyModel; }; - - -#endif //FLATPROXYMODEL_H