mpviewplugins/mpcollectionviewplugin/src/mpcollectionlistcontainer.cpp
changeset 20 82baf59ce8dd
parent 19 4e84c994a771
child 29 8192e5b5c935
equal deleted inserted replaced
19:4e84c994a771 20:82baf59ce8dd
    21 
    21 
    22 #include <hblistview.h>
    22 #include <hblistview.h>
    23 #include <hbabstractviewitem.h>
    23 #include <hbabstractviewitem.h>
    24 #include <hblistviewitem.h>
    24 #include <hblistviewitem.h>
    25 #include <hbscrollbar.h>
    25 #include <hbscrollbar.h>
       
    26 #include <hbdocumentloader.h>
       
    27 #include <hblabel.h>
       
    28 #include <hbindexfeedback.h>
    26 
    29 
    27 #include "mpcollectionlistcontainer.h"
    30 #include "mpcollectionlistcontainer.h"
    28 #include "mpcollectiondatamodel.h"
    31 #include "mpcollectiondatamodel.h"
    29 #include "mpmpxcollectiondata.h"
    32 #include "mpmpxcollectiondata.h"
    30 #include "mptrace.h"
    33 #include "mptrace.h"
    43  Constructs the collection container.
    46  Constructs the collection container.
    44  */
    47  */
    45 MpCollectionListContainer::MpCollectionListContainer( HbDocumentLoader *loader, QGraphicsItem *parent )
    48 MpCollectionListContainer::MpCollectionListContainer( HbDocumentLoader *loader, QGraphicsItem *parent )
    46     : MpCollectionContainer(loader, parent),
    49     : MpCollectionContainer(loader, parent),
    47       mList(0),
    50       mList(0),
    48       mEffectOnGoing(false)
    51       mNoMusic(0),
       
    52       mIndexFeedback( new HbIndexFeedback())
    49 {
    53 {
    50     TX_LOG
    54     TX_ENTRY
       
    55     mIndexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter);
       
    56     TX_EXIT
    51 }
    57 }
    52 
    58 
    53 /*!
    59 /*!
    54  Destructs the collection container.
    60  Destructs the collection container.
    55  */
    61  */
    56 MpCollectionListContainer::~MpCollectionListContainer()
    62 MpCollectionListContainer::~MpCollectionListContainer()
    57 {
    63 {
    58     TX_LOG
    64     TX_ENTRY
       
    65     delete mNoMusic;
       
    66     delete mIndexFeedback;
       
    67     TX_EXIT
    59 }
    68 }
    60 
    69 
    61 /*!
    70 /*!
    62  Initializes the collection container. Allocates all resources needed by the
    71  Initializes the collection container. Allocates all resources needed by the
    63  container.
    72  container.
    64  */
    73  */
    65 void MpCollectionListContainer::initialize()
    74 void MpCollectionListContainer::initialize()
    66 {
    75 {
    67     TX_ENTRY
    76     TX_LOG
    68     HbEffect::add(QString("viewItem"), QString(":/effects/select.fxml"),
       
    69         QString("chosen") );
       
    70     HbEffect::add(QString("viewItem"), QString(":/effects/select_end.fxml"),
       
    71         QString("chosenEnd") );
       
    72     TX_EXIT
       
    73 }
    77 }
    74 
    78 
    75 /*!
    79 /*!
    76  Sets the data model for the container.
    80  Sets the data model for the container.
    77  */
    81  */
    78 void MpCollectionListContainer::setDataModel( MpCollectionDataModel *dataModel )
    82 void MpCollectionListContainer::setDataModel( MpCollectionDataModel *dataModel )
    79 {
    83 {
    80     TX_ENTRY
    84     TX_ENTRY
    81     MpCollectionContainer::setDataModel(dataModel);
    85     MpCollectionContainer::setDataModel(dataModel);
    82     mList->setModel(0);
    86     if ( mList ) {
    83     mList->setModel(dataModel);
    87         mList->setModel(dataModel);
       
    88     }
    84     TX_EXIT
    89     TX_EXIT
    85 }
    90 }
    86 
    91 
    87 /*!
    92 /*!
    88  Slot to be called when an item is selected by the user.
    93  Slot to be called when an item is selected by the user.
    89  Start animation.
    94  Start animation.
    90  */
    95  */
    91 void MpCollectionListContainer::itemActivated( const QModelIndex &index )
    96 void MpCollectionListContainer::itemActivated( const QModelIndex &index )
    92 {
    97 {
    93     TX_ENTRY_ARGS("index=" << index.row());
    98     TX_ENTRY_ARGS("index=" << index.row());
    94     if ( !mEffectOnGoing ) {
    99     emit MpCollectionContainer::itemActivated( index.row() );
    95         HbAbstractViewItem *listViewItem = mList->itemByIndex(index);
       
    96         mEffectOnGoing = true;
       
    97         mChosenIndex = index;
       
    98         HbEffect::start(listViewItem, QString("viewItem"), QString("chosen"),
       
    99             this, "itemChosenFxComplete1");
       
   100     }
       
   101     TX_EXIT
   100     TX_EXIT
   102 }
   101 }
   103 
   102 
   104 /*!
   103 /*!
   105  Slot to be called when an item is long pressed by the user.
   104  Slot to be called when an item is long pressed by the user.
   110     emit MpCollectionContainer::itemLongPressed(listViewItem->modelIndex().row(), coords);
   109     emit MpCollectionContainer::itemLongPressed(listViewItem->modelIndex().row(), coords);
   111     TX_EXIT
   110     TX_EXIT
   112 }
   111 }
   113 
   112 
   114 /*!
   113 /*!
   115  Slot for item selected effects part 1.
       
   116  */
       
   117 void MpCollectionListContainer::itemChosenFxComplete1(
       
   118     const HbEffect::EffectStatus &status )
       
   119 {
       
   120     Q_UNUSED(status);
       
   121     HbAbstractViewItem *listViewItem = mList->itemByIndex(mChosenIndex);
       
   122     HbEffect::start(listViewItem, QString("viewItem"), QString("chosenEnd"),
       
   123         this, "itemChosenFxComplete2");
       
   124 }
       
   125 
       
   126 /*!
       
   127  Slot for item selected effects part 2. The end.
       
   128  */
       
   129 void MpCollectionListContainer::itemChosenFxComplete2(
       
   130     const HbEffect::EffectStatus &status )
       
   131 {
       
   132     Q_UNUSED(status);
       
   133     mEffectOnGoing = false;
       
   134     emit MpCollectionContainer::itemActivated( mChosenIndex.row() );
       
   135 }
       
   136 
       
   137 
       
   138 /*!
       
   139  \internal
   114  \internal
   140  */
   115  */
   141  void MpCollectionListContainer::initializeList()
   116 void MpCollectionListContainer::initializeList()
   142  {
   117 {
       
   118     TX_ENTRY
   143     mList->setItemRecycling(true);
   119     mList->setItemRecycling(true);
   144     mList->setScrollingStyle( HbListView::PanOrFlick );
   120     mList->setScrollingStyle( HbListView::PanOrFlick );
   145     mList->setClampingStyle( HbListView::BounceBackClamping );
   121     mList->setClampingStyle( HbListView::BounceBackClamping );
   146     mList->setLongPressEnabled(true);
   122     mList->setLongPressEnabled(true);
   147 
   123 
   152     scrollbar->show();
   128     scrollbar->show();
   153     scrollbar->setInteractive(true);
   129     scrollbar->setInteractive(true);
   154     mList->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
   130     mList->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
   155 
   131 
   156     mList->listItemPrototype()->setGraphicsSize(HbListViewItem::Thumbnail);
   132     mList->listItemPrototype()->setGraphicsSize(HbListViewItem::Thumbnail);
       
   133     TX_EXIT
   157 }
   134 }
   158 
   135 
       
   136 /*!
       
   137  \internal
       
   138  */
       
   139 void MpCollectionListContainer::setupEmptyListContainer()
       
   140 {
       
   141     TX_ENTRY
       
   142     bool ok = false;
       
   143     mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "emptyList", &ok);
       
   144     if ( !ok ) {
       
   145         TX_LOG_ARGS("Error: invalid xml file.");
       
   146         Q_ASSERT_X(ok, "MpCollectionListContainer::setupContainer", "invalid xml file");
       
   147     }
       
   148 
       
   149     QGraphicsWidget *widget;
       
   150     widget = mDocumentLoader->findWidget(QString("noMusic"));
       
   151     mNoMusic = qobject_cast<HbLabel*>(widget);
       
   152     TX_EXIT
       
   153 }
       
   154