modernize: Use nullptr
[quassel.git] / src / client / treemodel.h
index d645e76..7e097ec 100644 (file)
@@ -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,8 +18,9 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#ifndef TREEMODEL_H
-#define TREEMODEL_H
+#pragma once
+
+#include "client-export.h"
 
 #include <QList>
 #include <QStringList>
@@ -31,7 +32,7 @@
 /*****************************************
  *  general item used in the Tree Model
  *****************************************/
-class AbstractTreeItem : public QObject
+class CLIENT_EXPORT AbstractTreeItem : public QObject
 {
     Q_OBJECT
 
@@ -42,7 +43,7 @@ public:
     };
     Q_DECLARE_FLAGS(TreeItemFlags, TreeItemFlag)
 
-    AbstractTreeItem(AbstractTreeItem *parent = 0);
+    AbstractTreeItem(AbstractTreeItem *parent = nullptr);
 
     bool newChild(AbstractTreeItem *child);
     bool newChilds(const QList<AbstractTreeItem *> &items);
@@ -100,12 +101,12 @@ private:
 /*****************************************
  * SimpleTreeItem
  *****************************************/
-class SimpleTreeItem : public AbstractTreeItem
+class CLIENT_EXPORT SimpleTreeItem : public AbstractTreeItem
 {
     Q_OBJECT
 
 public:
-    SimpleTreeItem(const QList<QVariant> &data, AbstractTreeItem *parent = 0);
+    SimpleTreeItem(const QList<QVariant> &data, AbstractTreeItem *parent = nullptr);
     virtual ~SimpleTreeItem();
 
     virtual QVariant data(int column, int role) const;
@@ -121,33 +122,27 @@ private:
 /*****************************************
  * PropertyMapItem
  *****************************************/
-class PropertyMapItem : public AbstractTreeItem
+class CLIENT_EXPORT PropertyMapItem : public AbstractTreeItem
 {
     Q_OBJECT
 
 public:
-    PropertyMapItem(const QStringList &propertyOrder, AbstractTreeItem *parent = 0);
-    PropertyMapItem(AbstractTreeItem *parent = 0);
+    PropertyMapItem(AbstractTreeItem *parent = nullptr);
 
-    virtual ~PropertyMapItem();
+    virtual QStringList propertyOrder() const = 0;
 
     virtual QVariant data(int column, int role) const;
     virtual bool setData(int column, const QVariant &value, int role);
 
     virtual QString toolTip(int column) const { Q_UNUSED(column) return QString(); }
     virtual int columnCount() const;
-
-    void appendProperty(const QString &property);
-
-private:
-    QStringList _propertyOrder;
 };
 
 
 /*****************************************
  * TreeModel
  *****************************************/
-class TreeModel : public QAbstractItemModel
+class CLIENT_EXPORT TreeModel : public QAbstractItemModel
 {
     Q_OBJECT
 
@@ -157,9 +152,11 @@ public:
         UserRole
     };
 
-    TreeModel(const QList<QVariant> &, QObject *parent = 0);
+    TreeModel(const QList<QVariant> &, QObject *parent = nullptr);
     virtual ~TreeModel();
 
+    AbstractTreeItem *root() const;
+
     virtual QVariant data(const QModelIndex &index, int role) const;
     virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
 
@@ -208,6 +205,3 @@ private slots:
     void debug_rowsRemoved(const QModelIndex &parent, int start, int end);
     void debug_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
 };
-
-
-#endif