modernize: Prefer default member init over ctor init
[quassel.git] / src / uisupport / flatproxymodel.h
index e006760..84fb779 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-08 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  *
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#ifndef FLATPROXYMODEL_H
-#define FLATPROXYMODEL_H
+#pragma once
+
+#include "uisupport-export.h"
 
 #include <QAbstractProxyModel>
 
-class FlatProxyModel : public QAbstractProxyModel {
-  Q_OBJECT
+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;
-  void completenessTest() const;
+    void linkTest() const;
+    void completenessTest() const;
 
 private slots:
-  void on_columnsAboutToBeInserted(const QModelIndex &parent, int start, int end);
-  void on_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
-  void on_columnsInserted(const QModelIndex &parent, int start, int end);
-  void on_columnsRemoved(const QModelIndex &parent, int start, int end);
-  
-  void on_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+    void on_columnsAboutToBeInserted(const QModelIndex &parent, int start, int end);
+    void on_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+    void on_columnsInserted(const QModelIndex &parent, int start, int end);
+    void on_columnsRemoved(const QModelIndex &parent, int start, int end);
+
+    void on_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
 //   void on_headerDataChanged(Qt::Orientation orientation, int first, int last);
 
-  void on_layoutAboutToBeChanged();
-  void on_layoutChanged();
+    void on_layoutAboutToBeChanged();
+    void on_layoutChanged();
 
-  inline void on_modelAboutToBeReset() { reset(); }
-  // void on_modelReset();
+    inline void on_modelAboutToBeReset() { beginResetModel(); endResetModel(); }
+    // void on_modelReset();
 
-  void on_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
-  void on_rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
-  void on_rowsInserted(const QModelIndex &parent, int start, int end);
-  void on_rowsRemoved(const QModelIndex &parent, int start, int end);
+    void on_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
+    void on_rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+    void on_rowsInserted(const QModelIndex &parent, int start, int end);
+    void on_rowsRemoved(const QModelIndex &parent, int start, int end);
 
 private:
-  QList<int> _childCount;
+    QList<int> _childCount;
 
-  class SourceItem;
-  SourceItem *_rootSourceItem;
+    class SourceItem;
+    SourceItem *_rootSourceItem{nullptr};
 
-  void insertSubTree(const QModelIndex &source_idx, bool emitInsert = true);
-  SourceItem *insertSubTreeHelper(SourceItem *parentItem, SourceItem *lastItem_, const QModelIndex &source_idx);
+    void insertSubTree(const QModelIndex &source_idx, bool emitInsert = true);
+    SourceItem *insertSubTreeHelper(SourceItem *parentItem, SourceItem *lastItem_, const QModelIndex &source_idx);
 
-  void removeSubTree(const QModelIndex &source_idx, bool emitRemove = true);
+    void removeSubTree(const QModelIndex &source_idx, bool emitRemove = true);
 
-  SourceItem *sourceToInternal(const QModelIndex &sourceIndex) const;
+    SourceItem *sourceToInternal(const QModelIndex &sourceIndex) const;
 
-  void checkChildCount(const QModelIndex &index, const SourceItem *item, int &pos) const;
+    void checkChildCount(const QModelIndex &index, const SourceItem *item, int &pos) const;
 
-  class _RangeRect {
-  public:
-    int left, right, top, bottom;
-    SourceItem *topItem, *bottomItem;
-    bool operator<(const _RangeRect &other) const;
-  };
+    class _RangeRect
+    {
+public:
+        int left, right, top, bottom;
+        SourceItem *topItem, *bottomItem;
+        bool operator<(const _RangeRect &other) const;
+    };
 };
 
 
-class FlatProxyModel::SourceItem {
+class FlatProxyModel::SourceItem
+{
 public:
-  SourceItem(int row = 0, SourceItem *parent = 0);
-  ~SourceItem();
+    SourceItem(int row = 0, SourceItem *parent = nullptr);
+    ~SourceItem();
 
-  inline SourceItem *parent() const { return _parent; }
-  inline SourceItem *child(int i) const { return _childs[i]; }
-  inline int childCount() const { return _childs.count(); }
+    inline SourceItem *parent() const { return _parent; }
+    inline SourceItem *child(int i) const { return _childs[i]; }
+    inline int childCount() const { return _childs.count(); }
 
-  inline int pos() const { return _pos; }
-  inline SourceItem *next() const { return _next; }
+    inline int pos() const { return _pos; }
+    inline SourceItem *next() const { return _next; }
 
-  int sourceRow() const;
-  SourceItem *findChild(int proxyPos) const;
+    int sourceRow() const;
+    SourceItem *findChild(int proxyPos) const;
 
 private:
-  inline void removeChild(SourceItem *item) { _childs.removeAt(_childs.indexOf(item)); }
-  inline void setPos(int i) { _pos = i; }
-  inline void setNext(SourceItem *next) { _next = next; }
+    inline void removeChild(SourceItem *item) { _childs.removeAt(_childs.indexOf(item)); }
+    inline void setPos(int i) { _pos = i; }
+    inline void setNext(SourceItem *next) { _next = next; }
 
-  SourceItem *_parent;
-  QList<SourceItem *> _childs;
-  int _pos;
-  SourceItem *_next;
+    SourceItem *_parent;
+    QList<SourceItem *> _childs;
+    int _pos{-1};
+    SourceItem *_next{nullptr};
 
-  friend class FlatProxyModel;
+    friend class FlatProxyModel;
 };
-
-
-#endif //FLATPROXYMODEL_H