]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistviewaccessible.h
Prevent repeated re-layouting of all items while previews are generated
[dolphin.git] / src / kitemviews / kitemlistviewaccessible.h
index afc04797f95a77f85701a5e76cfd1e1b38bf3212..c2213cd67be435b1d415c19173e76a1399f98af6 100644 (file)
@@ -1,25 +1,42 @@
-#ifndef ACCESSIBLE_ITEMVIEWS_H
-#define ACCESSIBLE_ITEMVIEWS_H
+/***************************************************************************
+ *   Copyright (C) 2012 by Amandeep Singh <aman.dedman@gmail.com>          *
+ *                                                                         *
+ *   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            *
+ ***************************************************************************/
+
+#ifndef KITEMLISTVIEWACCESSIBLE_H
+#define KITEMLISTVIEWACCESSIBLE_H
 
-#include "QtCore/qpointer.h"
+#ifndef QT_NO_ACCESSIBILITY
+
+#include <QtCore/qpointer.h>
 #include <QtGui/qaccessible.h>
 #include <QtGui/qaccessible2.h>
 #include <QtGui/qaccessiblewidget.h>
+#include <QtGui/qaccessibleobject.h>
 
-#include "kitemlistview.h"
-#include "kitemlistcontainer.h"
-
-#ifndef QT_NO_ACCESSIBILITY
-
-class KItemListAccessibleCell;
+class KItemListView;
+class KItemListContainer;
 
 class KItemListViewAccessible: public QAccessibleTable2Interface, public QAccessibleObjectEx
 {
     Q_ACCESSIBLE_OBJECT
-public:
-    explicit KItemListViewAccessible(KItemListView *view);
 
-    virtual ~KItemListViewAccessible();
+public:
+    explicit KItemListViewAccessible(KItemListView* view);
 
     Role role(int child) const;
     State state(int child) const;
@@ -28,22 +45,22 @@ public:
 
     int childAt(int x, int y) const;
     int childCount() const;
-    int indexOfChild(const QAccessibleInterface *) const;
+    int indexOfChild(const QAccessibleInterface*) const;
 
-    int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const;
-    Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
+    int navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const;
+    Relation relationTo(int child, const QAccessibleInterfaceother, int otherChild) const;
 
 #ifndef QT_NO_ACTION
     int userActionCount(int child) const;
     QString actionText(int action, Text t, int child) const;
-    bool doAction(int action, int child, const QVariantList &params);
+    bool doAction(int action, int child, const QVariantListparams);
 #endif
-    QVariant invokeMethodEx(Method, int, const QVariantList &) { return QVariant(); }
+    QVariant invokeMethodEx(Method, int, const QVariantList&);
 
     // Table2 interface
-    virtual QAccessibleTable2CellInterface *cellAt(int row, int column) const;
-    virtual QAccessibleInterface *caption() const;
-    virtual QAccessibleInterface *summary() const;
+    virtual QAccessibleTable2CellInterfacecellAt(int row, int column) const;
+    virtual QAccessibleInterfacecaption() const;
+    virtual QAccessibleInterfacesummary() const;
     virtual QString columnDescription(int column) const;
     virtual QString rowDescription(int row) const;
     virtual int columnCount() const;
@@ -70,52 +87,41 @@ public:
     virtual bool unselectRow(int row);
     virtual bool unselectColumn(int column);
 
-    KItemListView *view() const;
+    KItemListViewview() const;
 
 protected:
     virtual void modelReset();
-    inline QAccessibleTable2CellInterface *cell(int index) const;
-    inline QAccessible::Role cellRole() const {
-        return QAccessible::Cell;
-    }
+    /**
+     * Create an QAccessibleTable2CellInterface representing the table
+     * cell at the @index. Index is 0-based.
+     */
+    inline QAccessibleTable2CellInterface* cell(int index) const;
+    inline QAccessible::Role cellRole() const;
 };
 
 class KItemListAccessibleCell: public QAccessibleTable2CellInterface
 {
 public:
-    KItemListAccessibleCell(KItemListView *view, int m_index);
+    KItemListAccessibleCell(KItemListViewview, int m_index);
 
-    QObject *object() const
-    {
-        return 0;
-    }
+    QObject* object() const;
     Role role(int) const;
     State state(int) const;
     QRect rect(int) const;
     bool isValid() const;
-
-    inline int childAt(int, int) const {
-        return 0;
-    }
-    inline int childCount() const {
-        return 0;
-    }
-    inline int indexOfChild(const QAccessibleInterface *) const {
-        return -1;
-    }
-
+    int childAt(int, int) const;
+    int childCount() const;
+    int indexOfChild(const QAccessibleInterface*) const;
     QString text(Text t, int child) const;
-    void setText(Text t, int child, const QString &text);
-
-    int navigate(RelationFlag relation, int m_index, QAccessibleInterface **iface) const;
-    Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
-
+    void setText(Text t, int child, const QString& text);
+    int navigate(RelationFlag relation, int m_index, QAccessibleInterface** interface) const;
+    Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const;
     bool isExpandable() const;
 
 #ifndef QT_NO_ACTION
     int userActionCount(int child) const;
     QString actionText(int action, Text t, int child) const;
-    bool doAction(int action, int child, const QVariantList &params);
+    bool doAction(int action, int child, const QVariantListparams);
 #endif
 
     // Cell Interface
@@ -126,37 +132,32 @@ public:
     virtual QList<QAccessibleInterface*> rowHeaderCells() const;
     virtual int rowIndex() const;
     virtual bool isSelected() const;
-    virtual void rowColumnExtents(int *row, int *column, int *rowExtents, int *columnExtents, bool *selected) const;
+    virtual void rowColumnExtents(int* row, int* column, int* rowExtents, int* columnExtents, bool* selected) const;
     virtual QAccessibleTable2Interface* table() const;
 
-    inline int index() const {
-        return m_index;
-    }
+    inline int index() const;
 
 private:
     QPointer<KItemListView> m_view;
     int m_index;
-
-friend class KItemListViewAccessible;
 };
 
 class KItemListContainerAccessible : public QAccessibleWidgetEx
 {
     Q_ACCESSIBLE_OBJECT
+
 public:
-    explicit KItemListContainerAccessible(KItemListContainer*);
+    explicit KItemListContainerAccessible(KItemListContainer* container);
     virtual ~KItemListContainerAccessible();
-    int childCount () const;
-    int indexOfChild ( const QAccessibleInterface * child ) const;
-    int navigate ( RelationFlag relation, int entry, QAccessibleInterface ** target ) const;
+
+    int childCount() const;
+    int indexOfChild(const QAccessibleInterface* child) const;
+    int navigate(RelationFlag relation, int entry, QAccessibleInterface** target) const;
 
 private:
-    inline KItemListContainer *container() const
-    {
-        return static_cast<KItemListContainer *>(object());
-    }
+    const KItemListContainer* container() const;
 };
 
 #endif // QT_NO_ACCESSIBILITY
 
-#endif // ACCESSIBLE_ITEMVIEWS_H
+#endif