]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemmodelbase.h
Merge branch 'release/20.12'
[dolphin.git] / src / kitemviews / kitemmodelbase.h
index a7773ee3b36163e996939c7dd78f0dda3c760d2c..d68eab568e4ec4379385ad8756e0b1ec3ee07971 100644 (file)
@@ -1,36 +1,21 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   Based on the Itemviews NG project from Trolltech Labs:                *
- *   http://qt.gitorious.org/qt-labs/itemviews-ng                          *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   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.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
+ *
+ * Based on the Itemviews NG project from Trolltech Labs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #ifndef KITEMMODELBASE_H
 #define KITEMMODELBASE_H
 
 #include "dolphin_export.h"
+#include "kitemviews/kitemrange.h"
+#include "kitemviews/kitemset.h"
 
-#include <kitemviews/kitemrange.h>
-#include <kitemviews/kitemset.h>
-
-#include <QUrl>
 #include <QHash>
 #include <QObject>
+#include <QUrl>
 #include <QVariant>
 
 class QMimeData;
@@ -55,9 +40,9 @@ class DOLPHIN_EXPORT KItemModelBase : public QObject
     Q_OBJECT
 
 public:
-    KItemModelBase(QObject* parent = 0);
-    explicit KItemModelBase(const QByteArray& sortRole, QObject* parent = 0);
-    virtual ~KItemModelBase();
+    explicit KItemModelBase(QObject* parent = nullptr);
+    explicit KItemModelBase(const QByteArray& sortRole, QObject* parent = nullptr);
+    ~KItemModelBase() override;
 
     /** @return The number of items. */
     virtual int count() const = 0;
@@ -86,8 +71,9 @@ public:
      * Sets the sort-role to \a role. The method KItemModelBase::onSortRoleChanged() will be
      * called so that model-implementations can react on the sort-role change. Afterwards the
      * signal sortRoleChanged() will be emitted.
+     * The implementation should resort only if \a resortItems is true.
      */
-    void setSortRole(const QByteArray& role);
+    void setSortRole(const QByteArray& role, bool resortItems = true);
     QByteArray sortRole() const;
 
     /**
@@ -267,8 +253,9 @@ protected:
      * Usually the most efficient way is to emit a
      * itemsRemoved() signal for all items, reorder the items internally and to emit a
      * itemsInserted() signal afterwards.
+     * The implementation should resort only if \a resortItems is true.
      */
-    virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous);
+    virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems = true);
 
     /**
      * Is invoked if the sort order has been changed by KItemModelBase::setSortOrder(). Allows