X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/362817d1834f2ada3ea4552a25fa39bbbb540f8c..d48b733:/src/kitemviews/kitemmodelbase.h diff --git a/src/kitemviews/kitemmodelbase.h b/src/kitemviews/kitemmodelbase.h index 1dffaf8cf..bd5ca1d65 100644 --- a/src/kitemviews/kitemmodelbase.h +++ b/src/kitemviews/kitemmodelbase.h @@ -23,29 +23,21 @@ #ifndef KITEMMODELBASE_H #define KITEMMODELBASE_H -#include +#include "dolphin_export.h" + +#include +#include #include #include -#include #include class QMimeData; -struct KItemRange -{ - KItemRange(int index = 0, int count = 0); - int index; - int count; - - bool operator == (const KItemRange& other) const; -}; -typedef QList KItemRangeList; - /** * @brief Base class for model implementations used by KItemListView and KItemListController. * - * A item-model consists of a variable number of items. The number of items + * An item-model consists of a variable number of items. The number of items * is given by KItemModelBase::count(). The data of an item is accessed by a unique index * with KItemModelBase::data(). The indexes are integer-values counting from 0 to the * KItemModelBase::count() - 1. @@ -55,15 +47,15 @@ typedef QList KItemRangeList; * A model can optionally provide sorting- and grouping-capabilities. * * Also optionally it is possible to provide a tree of items by implementing the methods - * setExpanded(), isExpanded() and isExpandable(). + * setExpanded(), isExpanded(), isExpandable() and expandedParentsCount(). */ -class LIBDOLPHINPRIVATE_EXPORT KItemModelBase : public QObject +class DOLPHIN_EXPORT KItemModelBase : public QObject { Q_OBJECT public: KItemModelBase(QObject* parent = 0); - KItemModelBase(const QByteArray& sortRole, QObject* parent = 0); + explicit KItemModelBase(const QByteArray& sortRole, QObject* parent = 0); virtual ~KItemModelBase(); /** @return The number of items. */ @@ -145,12 +137,19 @@ public: */ virtual bool isExpandable(int index) const; + /** + * @return Number of expanded parent items for the item with the given index. + * Per default 0 is returned. + */ + virtual int expandedParentsCount(int index) const; + /** * @return MIME-data for the items given by \a indexes. The default implementation * returns 0. The ownership of the returned instance is in the hand of the - * caller of this method. + * caller of this method. The method must be implemented if dragging of + * items should be possible. */ - virtual QMimeData* createMimeData(const QSet& indexes) const; + virtual QMimeData* createMimeData(const KItemSet& indexes) const; /** * @return Reimplement this to return the index for the first item @@ -211,11 +210,20 @@ signals: * with the items 5 and 6 then the parameters look like this: * - itemRange: has the index 0 and a count of 7. * - movedToIndexes: Contains the seven values 5, 6, 2, 3, 4, 0, 1 + * + * 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& movedToIndexes); void itemsChanged(const KItemRangeList& itemRanges, const QSet& roles); + /** + * Is emitted if the groups have changed, even though the order of the + * items has not been modified. + */ + void groupsChanged(); + void groupedSortingChanged(bool current); void sortRoleChanged(const QByteArray& current, const QByteArray& previous); void sortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous);