]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.h
Merge remote-tracking branch 'fork/work/zakharafoniam/useful-groups'
[dolphin.git] / src / kitemviews / kitemlistview.h
index ff51af92243d4deb75a0d35714891fe41028a758..1382405d058b89e87fe218cd6a6bd12cc20e8e89 100644 (file)
@@ -21,6 +21,8 @@
 #include <QGraphicsWidget>
 #include <QSet>
 
+class KItemListContainer;
+class KItemListContainerAccessible;
 class KItemListController;
 class KItemListGroupHeaderCreatorBase;
 class KItemListHeader;
@@ -57,6 +59,9 @@ class DOLPHIN_EXPORT KItemListView : public QGraphicsWidget
     Q_PROPERTY(qreal itemOffset READ itemOffset WRITE setItemOffset NOTIFY itemOffsetChanged)
 
 public:
+    /** The position in the view to which an item should be scrolled to. */
+    enum ViewItemPosition { Beginning, Middle, End, Nearest };
+
     explicit KItemListView(QGraphicsWidget *parent = nullptr);
     ~KItemListView() override;
 
@@ -142,6 +147,18 @@ public:
     void setGroupHeaderCreator(KItemListGroupHeaderCreatorBase *groupHeaderCreator);
     KItemListGroupHeaderCreatorBase *groupHeaderCreator() const;
 
+#ifndef QT_NO_ACCESSIBILITY
+    /**
+     * Uses \a parent to create an accessible object for \a parent. That accessible object will
+     * then be used as the accessible parent of the accessible object for this KItemListView.
+     * Make sure \a parent is the container which contains this specific KItemListView.
+     * This method must be called once before the accessible interface is queried for this class.
+     */
+    void setAccessibleParentsObject(KItemListContainer *accessibleParentsObject);
+    /** The parent of the QAccessibilityInterface of this class. */
+    KItemListContainerAccessible *accessibleParent();
+#endif
+
     /**
      * @return The basic size of all items. The size of an item may be larger than
      *         the basic size (see KItemListView::itemRect()).
@@ -158,6 +175,11 @@ public:
      */
     qreal verticalPageStep() const;
 
+    /**
+     * @return The line step which should be used for the scroll by mouse wheel.
+     */
+    virtual qreal scrollSingleStep() const;
+
     /**
      * @return Index of the item that is below the point \a pos.
      *         The position is relative to the upper right of
@@ -237,9 +259,10 @@ public:
 
     /**
      * Scrolls to the item with the index \a index so that the item
-     * will be fully visible.
+     * will be fully visible. The item is positioned within the view
+     * as specified by \a viewItemPosition.
      */
-    void scrollToItem(int index);
+    void scrollToItem(int index, ViewItemPosition viewItemPosition = ViewItemPosition::Nearest);
 
     /**
      * If several properties of KItemListView are changed synchronously, it is
@@ -284,6 +307,12 @@ public:
 
     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
 
+    /**
+     * Set the bottom offset for moving the view so that the small overlayed statusbar
+     * won't cover any items by accident.
+     */
+    void setStatusBarOffset(int offset);
+
 Q_SIGNALS:
     void scrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
     void scrollOffsetChanged(qreal current, qreal previous);
@@ -412,6 +441,8 @@ protected Q_SLOTS:
     virtual void slotGroupedSortingChanged(bool current);
     virtual void slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous);
     virtual void slotSortRoleChanged(const QByteArray &current, const QByteArray &previous);
+    virtual void slotGroupOrderChanged(Qt::SortOrder current, Qt::SortOrder previous);
+    virtual void slotGroupRoleChanged(const QByteArray &current, const QByteArray &previous);
     virtual void slotCurrentChanged(int current, int previous);
     virtual void slotSelectionChanged(const KItemSet &current, const KItemSet &previous);
 
@@ -534,8 +565,9 @@ private:
     void recycleGroupHeaderForWidget(KItemListWidget *widget);
 
     /**
-     * Helper method for slotGroupedSortingChanged(), slotSortOrderChanged()
-     * and slotSortRoleChanged(): Iterates through all visible items and updates
+     * Helper method for slotGroupedSortingChanged(), slotSortOrderChanged(),
+     * slotSortRoleChanged(), slotGroupOrderChanged() and slotGroupRoleChanged():
+     * Iterates through all visible items and updates
      * the group-header widgets.
      */
     void updateVisibleGroupHeaders();
@@ -711,6 +743,10 @@ private:
     QList<QByteArray> m_visibleRoles;
     mutable KItemListWidgetCreatorBase *m_widgetCreator;
     mutable KItemListGroupHeaderCreatorBase *m_groupHeaderCreator;
+#ifndef QT_NO_ACCESSIBILITY
+    /** The object that will be the parent of this classes QAccessibleInterface. */
+    KItemListContainerAccessible *m_accessibleParent = nullptr;
+#endif
     KItemListStyleOption m_styleOption;
 
     QHash<int, KItemListWidget *> m_visibleItems;
@@ -754,6 +790,8 @@ private:
 
     QPropertyAnimation *m_indicatorAnimation;
 
+    int m_statusBarOffset;
+
     // When dragging items into the view where the sort-role of the model
     // is empty, a visual indicator should be shown during dragging where
     // the dropping will happen. This indicator is specified by an index
@@ -771,7 +809,9 @@ private:
     friend class KItemListController;
     friend class KItemListControllerTest;
     friend class KItemListViewAccessible;
-    friend class KItemListAccessibleCell;
+    friend class KItemListDelegateAccessible;
+
+    friend class DolphinMainWindowTest;
 };
 
 /**