]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemmodelbase.h
GIT_SILENT Update Appstream for new release
[dolphin.git] / src / kitemviews / kitemmodelbase.h
index a6ba3f7c4ec888adb461bd5b893afc1862dda13d..42a9c54c94ca915474a305bffee18c309cd59914 100644 (file)
@@ -1,23 +1,10 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   Based on the Itemviews NG project from Trolltech Labs                 *
- *                                                                         *
- *   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
@@ -53,8 +40,8 @@ class DOLPHIN_EXPORT KItemModelBase : public QObject
     Q_OBJECT
 
 public:
-    explicit KItemModelBase(QObjectparent = nullptr);
-    explicit KItemModelBase(const QByteArray& sortRole, QObject* parent = nullptr);
+    explicit KItemModelBase(QObject *parent = nullptr);
+    explicit KItemModelBase(const QByteArray &sortRole, QObject *parent = nullptr);
     ~KItemModelBase() override;
 
     /** @return The number of items. */
@@ -69,7 +56,7 @@ public:
      * The default implementation does not set the data, and will always return
      * false.
      */
-    virtual bool setData(int index, const QHash<QByteArray, QVariant>values);
+    virtual bool setData(int index, const QHash<QByteArray, QVariant> &values);
 
     /**
      * Enables/disables the grouped sorting. The method KItemModelBase::onGroupedSortingChanged() will be
@@ -86,7 +73,7 @@ public:
      * signal sortRoleChanged() will be emitted.
      * The implementation should resort only if \a resortItems is true.
      */
-    void setSortRole(const QByteArrayrole, bool resortItems = true);
+    void setSortRole(const QByteArray &role, bool resortItems = true);
     QByteArray sortRole() const;
 
     /**
@@ -101,7 +88,7 @@ public:
      * @return Translated description for the \p role. The description is e.g. used
      *         for the header in KItemListView.
      */
-    virtual QString roleDescription(const QByteArrayrole) const;
+    virtual QString roleDescription(const QByteArray &role) const;
 
     /**
      * @return List of group headers. Each list-item consists of the index of the item
@@ -109,7 +96,7 @@ public:
      *         as QVariant. The value is shown by an instance of KItemListGroupHeader.
      *         Per default an empty list is returned.
      */
-    virtual QList<QPair<int, QVariant> > groups() const;
+    virtual QList<QPair<int, QVariant>> groups() const;
 
     /**
      * Expands the item with the index \a index if \a expanded is true.
@@ -149,7 +136,7 @@ public:
      *         caller of this method. The method must be implemented if dragging of
      *         items should be possible.
      */
-    virtual QMimeData* createMimeData(const KItemSet& indexes) const;
+    virtual QMimeData *createMimeData(const KItemSet &indexes) const;
 
     /**
      * @return Reimplement this to return the index for the first item
@@ -157,7 +144,7 @@ public:
      * @param text              the text which has been typed in through the keyboard
      * @param startFromIndex    the index from which to start searching from
      */
-    virtual int indexForKeyboardSearch(const QStringtext, int startFromIndex = 0) const;
+    virtual int indexForKeyboardSearch(const QString &text, int startFromIndex = 0) const;
 
     /**
      * @return True, if the item with the index \a index basically supports dropping.
@@ -172,6 +159,15 @@ public:
     // decision whether it accepts the drop?
     virtual bool supportsDropping(int index) const;
 
+    /**
+     * @return True, if the item with the index \a index can be entered in during hover actions.
+     *         Per default false is returned.
+     *
+     *         This is used to check that if the item
+     *         we're hovering on is either directory or a desktop file.
+     */
+    virtual bool canEnterOnHover(int index) const;
+
     /**
      * @return An internal mimetype to signal that an itemDropEvent() should be rejected by
      *         the receiving model.
@@ -196,7 +192,7 @@ public:
      * @return Parent directory of the items that are shown
      */
     virtual QUrl directory() const;
-signals:
+Q_SIGNALS:
     /**
      * Is emitted if one or more items have been inserted. Each item-range consists
      * of:
@@ -209,7 +205,7 @@ signals:
      * - They don't overlap
      * - The index of item-range n is smaller than the index of item-range n + 1.
      */
-    void itemsInserted(const KItemRangeListitemRanges);
+    void itemsInserted(const KItemRangeList &itemRanges);
 
     /**
      * Is emitted if one or more items have been removed. Each item-range consists
@@ -223,7 +219,7 @@ signals:
      * - They don't overlap
      * - The index of item-range n is smaller than the index of item-range n + 1.
      */
-    void itemsRemoved(const KItemRangeListitemRanges);
+    void itemsRemoved(const KItemRangeList &itemRanges);
 
     /**
      * Is emitted if one ore more items get moved.
@@ -238,9 +234,9 @@ signals:
      * This signal implies that the groups might have changed. Therefore,
      * gropusChanged() is not emitted if this signal is emitted.
      */
-    void itemsMoved(const KItemRange& itemRange, const QList<int>& movedToIndexes);
+    void itemsMoved(const KItemRange &itemRange, const QList<int> &movedToIndexes);
 
-    void itemsChanged(const KItemRangeList& itemRanges, const QSet<QByteArray>& roles);
+    void itemsChanged(const KItemRangeList &itemRanges, const QSet<QByteArray> &roles);
 
     /**
      * Is emitted if the groups have changed, even though the order of the
@@ -249,7 +245,7 @@ signals:
     void groupsChanged();
 
     void groupedSortingChanged(bool current);
-    void sortRoleChanged(const QByteArray& current, const QByteArray& previous);
+    void sortRoleChanged(const QByteArray &current, const QByteArray &previous);
     void sortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous);
 
 protected:
@@ -268,7 +264,7 @@ protected:
      * itemsInserted() signal afterwards.
      * The implementation should resort only if \a resortItems is true.
      */
-    virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems = true);
+    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
@@ -292,5 +288,3 @@ inline Qt::SortOrder KItemModelBase::sortOrder() const
 }
 
 #endif
-
-