hgwidgets_plat/ganeswidgets_api/inc/hgwidgets.h
changeset 20 a60f8b6b1d32
parent 17 a10844a9914d
child 21 53314abf04ed
equal deleted inserted replaced
17:a10844a9914d 20:a60f8b6b1d32
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef HGWIDGET_H
       
    19 #define HGWIDGET_H
       
    20 
       
    21 #include <QItemSelectionModel>
       
    22 #include <HbGlobal>
       
    23 #include <hbnamespace.h>
       
    24 #include <HbWidget>
       
    25 
       
    26 #ifdef BUILD_HG_WIDGETS
       
    27 #    define HG_WIDGETS_EXPORT Q_DECL_EXPORT
       
    28 #    define HG_WIDGETS_PRIVATE_EXPORT Q_DECL_EXPORT
       
    29 #else
       
    30 #    define HG_WIDGETS_EXPORT Q_DECL_IMPORT
       
    31 #    define HG_WIDGETS_PRIVATE_EXPORT Q_DECL_IMPORT
       
    32 #endif // BUILD_HG_WIDGETS
       
    33 
       
    34 class HgWidgetPrivate;
       
    35 class HbScrollBar;
       
    36 
       
    37 class HG_WIDGETS_EXPORT HgWidget : public HbWidget
       
    38 {
       
    39     Q_OBJECT
       
    40     Q_PROPERTY(bool longPressEnabled  READ longPressEnabled  WRITE setLongPressEnabled )
       
    41     Q_PROPERTY(ScrollBarPolicy scrollBarPolicy READ scrollBarPolicy WRITE setScrollBarPolicy)
       
    42     Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
       
    43     Q_PROPERTY(IndexFeedbackPolicy IndexFeedbackPolicy READ indexFeedbackPolicy WRITE setIndexFeedbackPolicy)
       
    44     Q_PROPERTY(ItemSizePolicy ItemSizePolicy READ itemSizePolicy WRITE setItemSizePolicy)
       
    45     Q_PROPERTY(QSizeF itemSize READ itemSize WRITE setItemSize)
       
    46     Q_PROPERTY(QSizeF itemSpacing READ itemSpacing WRITE setItemSpacing)
       
    47     Q_ENUMS(ScrollBarPolicy)
       
    48     Q_ENUMS(HgWidgetType)
       
    49     Q_ENUMS(SelectionMode)
       
    50     Q_ENUMS(IndexFeedbackPolicy)
       
    51     Q_ENUMS(ItemSizePolicy)
       
    52 public:
       
    53 
       
    54     enum HgDataRole
       
    55     {
       
    56         HgVisibilityRole = Qt::UserRole + 1
       
    57     };
       
    58 
       
    59     enum IndexFeedbackPolicy {
       
    60         IndexFeedbackNone = 0,
       
    61         IndexFeedbackSingleCharacter,
       
    62         IndexFeedbackThreeCharacter,
       
    63         IndexFeedbackString
       
    64     };
       
    65 
       
    66     enum ScrollBarPolicy {
       
    67         ScrollBarAsNeeded = Qt::ScrollBarAsNeeded,
       
    68         ScrollBarAlwaysOff = Qt::ScrollBarAlwaysOff,
       
    69         ScrollBarAlwaysOn = Qt::ScrollBarAlwaysOn,
       
    70         ScrollBarAutoHide
       
    71     };
       
    72 
       
    73     enum ItemSizePolicy {
       
    74         ItemSizeAutomatic,
       
    75         ItemSizeUserDefined
       
    76     };
       
    77 
       
    78     explicit HgWidget (QGraphicsItem *parent = 0);
       
    79     virtual ~HgWidget ();
       
    80 
       
    81     virtual void setModel(QAbstractItemModel *model);
       
    82     QAbstractItemModel *model() const;
       
    83 
       
    84     void setSelectionModel(QItemSelectionModel *selectionModel);
       
    85     QItemSelectionModel *selectionModel() const;
       
    86 
       
    87     enum SelectionMode {
       
    88         NoSelection = 0,
       
    89         SingleSelection,
       
    90         MultiSelection,
       
    91         ContiguousSelection
       
    92     };
       
    93 
       
    94     SelectionMode selectionMode() const;
       
    95     void setSelectionMode(SelectionMode mode, bool resetSelection = true);
       
    96     void selectAll();
       
    97     void clearSelection();
       
    98 
       
    99     QModelIndex currentIndex() const;
       
   100     void setCurrentIndex(const QModelIndex &index,
       
   101         QItemSelectionModel::SelectionFlags selectionFlag=QItemSelectionModel::NoUpdate);
       
   102 
       
   103     void scrollTo(const QModelIndex &index);
       
   104 
       
   105     bool longPressEnabled() const;
       
   106     void setLongPressEnabled(bool value);
       
   107 
       
   108     ScrollBarPolicy scrollBarPolicy() const;
       
   109     void setScrollBarPolicy(ScrollBarPolicy policy);
       
   110     HbScrollBar *scrollBar() const;
       
   111     void setScrollBar(HbScrollBar *scrollBar);
       
   112 
       
   113     bool getItemOutline(const QModelIndex& index, QPolygonF& points);
       
   114     Qt::Orientation scrollDirection() const;
       
   115 
       
   116     QList<QModelIndex> getVisibleItemIndices() const;
       
   117 
       
   118     void setIndexFeedbackPolicy( IndexFeedbackPolicy policy);
       
   119     IndexFeedbackPolicy indexFeedbackPolicy() const;
       
   120 
       
   121     void setDefaultImage(QImage defaultImage);
       
   122 
       
   123     void setItemSizePolicy(ItemSizePolicy policy);
       
   124     ItemSizePolicy itemSizePolicy() const;
       
   125 
       
   126     void setItemSize(const QSizeF& size);
       
   127     QSizeF itemSize() const;
       
   128 
       
   129     void setItemSpacing(const QSizeF& spacing);
       
   130     QSizeF itemSpacing() const;
       
   131 
       
   132 signals:
       
   133     void activated(const QModelIndex &index);
       
   134     void longPressed(const QModelIndex &index, const QPointF &coords);
       
   135     void scrollingStarted();
       
   136     void scrollingEnded();
       
   137 public slots:
       
   138 
       
   139     void aboutToChangeOrientation();
       
   140     void orientationChanged(Qt::Orientation orientation);
       
   141 
       
   142 protected slots:
       
   143 
       
   144     void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
       
   145 
       
   146 protected:
       
   147     HgWidgetPrivate * const p_ptr;
       
   148     HgWidget(HgWidgetPrivate &dd, QGraphicsItem *parent);
       
   149 
       
   150     bool eventFilter(QObject *obj,QEvent *event);
       
   151 
       
   152     bool event(QEvent *event);
       
   153 
       
   154 private:
       
   155     Q_DECLARE_PRIVATE_D(p_ptr, HgWidget)
       
   156     Q_DISABLE_COPY(HgWidget)
       
   157     Q_PRIVATE_SLOT(d_func(), void _q_scrollPositionChanged(qreal index, bool scrollBarAnimation))
       
   158     Q_PRIVATE_SLOT(d_func(), void _q_releaseItems(int releaseStart, int releaseEnd))
       
   159     Q_PRIVATE_SLOT(d_func(), void _q_requestItems(int requestStart, int requestEnd))
       
   160     Q_PRIVATE_SLOT(d_func(), void _q_hideScrollBars() )
       
   161     Q_PRIVATE_SLOT(d_func(), void _q_thumbPositionChanged(qreal value, Qt::Orientation orientation))
       
   162     Q_PRIVATE_SLOT(d_func(), void _q_insertRows(const QModelIndex &parent, int start, int end))
       
   163     Q_PRIVATE_SLOT(d_func(), void _q_removeRows(const QModelIndex &parent, int start, int end))
       
   164     Q_PRIVATE_SLOT(d_func(), void _q_moveRows(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow))
       
   165     Q_PRIVATE_SLOT(d_func(), void _q_groovePressed(qreal, Qt::Orientation))
       
   166     Q_PRIVATE_SLOT(d_func(), void _q_modelReset())
       
   167     Q_PRIVATE_SLOT(d_func(), void _q_updateCurrentItem(const QModelIndex &current, const QModelIndex &previous))
       
   168     Q_PRIVATE_SLOT(d_func(), void _q_themeChanged())
       
   169 };
       
   170 
       
   171 #endif  //HGWIDGET_H
       
   172