src/hbwidgets/itemviews/hbabstractviewitem.h
changeset 0 16d8024aca5e
child 1 f7ac710697a9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbWidgets module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 #ifndef HBABSTRACTVIEWITEM_H
       
    26 #define HBABSTRACTVIEWITEM_H
       
    27 
       
    28 #include <hbwidget.h>
       
    29 #include <hbglobal.h>
       
    30 #include <hbnamespace.h>
       
    31 #include <hbeffect.h>
       
    32 
       
    33 QT_BEGIN_NAMESPACE
       
    34 class QModelIndex;
       
    35 QT_END_NAMESPACE
       
    36 
       
    37 class HbAbstractViewItemPrivate;
       
    38 class HbAbstractItemView;
       
    39 class HbStyleOptionAbstractViewItem;
       
    40 class HbStyleParameters;
       
    41 class HbFrameBackground;
       
    42 
       
    43 class HB_WIDGETS_EXPORT HbAbstractViewItem : public HbWidget
       
    44 {
       
    45     Q_OBJECT
       
    46 
       
    47     Q_PROPERTY(Hb::ModelItemType modelItemType READ modelItemType)
       
    48 
       
    49 public:
       
    50 
       
    51     enum StateKey
       
    52     { 
       
    53         FocusKey,
       
    54         CheckStateKey,
       
    55         UserKey = 100
       
    56     };
       
    57     
       
    58     explicit HbAbstractViewItem(QGraphicsItem *parent=0);
       
    59     virtual ~HbAbstractViewItem();
       
    60 
       
    61     enum { Type = Hb::ItemType_AbstractViewItem };
       
    62     int type() const;
       
    63 
       
    64     virtual HbAbstractViewItem *createItem() = 0;
       
    65     virtual void updateChildItems();
       
    66 
       
    67     QModelIndex modelIndex() const;
       
    68     virtual bool canSetModelIndex(const QModelIndex &index) const;
       
    69     virtual void setModelIndex(const QModelIndex &index);
       
    70 
       
    71     HbAbstractViewItem *prototype() const;
       
    72 
       
    73     HbAbstractItemView *itemView() const;
       
    74     void setItemView(HbAbstractItemView *itemView);
       
    75     
       
    76     bool isFocused() const;
       
    77     virtual void receivedFocus();
       
    78     virtual void lostFocus();
       
    79 
       
    80     virtual QMap<int,QVariant> state() const;
       
    81     virtual void setState(const QMap<int,QVariant> &state);
       
    82     virtual bool selectionAreaContains(const QPointF &scenePosition) const;
       
    83 
       
    84     virtual QGraphicsItem *primitive(HbStyle::Primitive primitive) const;
       
    85 
       
    86     void setCheckState(Qt::CheckState state);
       
    87     Qt::CheckState checkState() const;
       
    88 
       
    89     void setDefaultFrame(const HbFrameBackground &frame);
       
    90     HbFrameBackground defaultFrame() const;
       
    91 
       
    92     void setPressed(bool pressed, bool animate=true);
       
    93     bool isPressed() const;
       
    94 
       
    95     Hb::ModelItemType modelItemType() const;
       
    96 
       
    97 public slots:
       
    98     void updatePrimitives();
       
    99 
       
   100 protected:
       
   101 
       
   102     HbAbstractViewItem(const HbAbstractViewItem &source);
       
   103     HbAbstractViewItem &operator=(const HbAbstractViewItem &source);
       
   104 
       
   105     HbAbstractViewItem( HbAbstractViewItemPrivate &dd, QGraphicsItem *parent );
       
   106     void initStyleOption(HbStyleOptionAbstractViewItem *option) const;
       
   107     virtual void polish(HbStyleParameters& params);
       
   108 
       
   109     virtual bool event(QEvent *e);
       
   110 
       
   111     virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
       
   112     virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
       
   113     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
       
   114 
       
   115     virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
       
   116 
       
   117     virtual void pressStateChanged(bool value, bool animate);
       
   118 
       
   119 private:
       
   120     Q_DECLARE_PRIVATE_D( d_ptr, HbAbstractViewItem )
       
   121     Q_PRIVATE_SLOT(d_func(), void _q_animationFinished(const HbEffect::EffectStatus &status))
       
   122 };
       
   123 
       
   124 #endif /*HBABSTRACTVIEWITEM_H*/