mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontaineralbums.cpp
author hgs
Fri, 09 Jul 2010 16:27:03 -0500
changeset 43 0f32e550d9d8
parent 37 eb79a7c355bf
child 51 560ce2306a17
permissions -rw-r--r--
201027
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description: Music Player collection container definition - Albums.
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include <QtCore>
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <hbdocumentloader.h>
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <hblistview.h>
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <hbgroupbox.h>
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <hbindexfeedback.h>
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
35
hgs
parents: 20
diff changeset
    25
#include <hgmediawall.h>
hgs
parents: 20
diff changeset
    26
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include "mpcollectioncontaineralbums.h"
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include "mpmpxcollectiondata.h"
35
hgs
parents: 20
diff changeset
    29
#include "mpcollectiondatamodel.h"
hgs
parents: 20
diff changeset
    30
#include "mpcollectiontbonelistdatamodel.h"
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "mptrace.h"
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
/*!
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
    \class MpCollectionContainerAlbums
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
    \brief Music Player collection container definition - Albums.
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
    'Albums' collection container implements the interface specified
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
    by MpCollectionContainer. It provides a layout and widgets for the
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
    'Albums' view.
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
    This container handles the following contexts:
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
    \li ECollectionContextAlbums
35
hgs
parents: 20
diff changeset
    43
    \li ECollectionContextAlbumsTBone
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
    \sa MpCollectionContainer
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
*/
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
/*!
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
 Constructs the collection container.
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
 */
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
MpCollectionContainerAlbums::MpCollectionContainerAlbums( HbDocumentLoader *loader, QGraphicsItem *parent )
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
    : MpCollectionListContainer(loader, parent),
35
hgs
parents: 20
diff changeset
    53
      mInfoBar(0),
hgs
parents: 20
diff changeset
    54
      mTBone(0),
hgs
parents: 20
diff changeset
    55
      mTBoneListModel(0),
hgs
parents: 20
diff changeset
    56
      mCurrentAlbumIndex(0)
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
{
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
    TX_LOG
35
hgs
parents: 20
diff changeset
    59
    mCollectionContext = ECollectionContextAlbums;
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
}
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
/*!
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
 Destructs the collection container.
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
 */
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
MpCollectionContainerAlbums::~MpCollectionContainerAlbums()
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
{
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
    TX_ENTRY
35
hgs
parents: 20
diff changeset
    68
	delete mInfoBar;
hgs
parents: 20
diff changeset
    69
    delete mTBone;
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
    delete mList;
35
hgs
parents: 20
diff changeset
    71
    delete mTBoneListModel;
hgs
parents: 20
diff changeset
    72
    TX_EXIT
hgs
parents: 20
diff changeset
    73
}
hgs
parents: 20
diff changeset
    74
hgs
parents: 20
diff changeset
    75
/*!
hgs
parents: 20
diff changeset
    76
 Sets the data model for the container.
hgs
parents: 20
diff changeset
    77
 */
hgs
parents: 20
diff changeset
    78
void MpCollectionContainerAlbums::setDataModel( MpCollectionDataModel *dataModel )
hgs
parents: 20
diff changeset
    79
{
hgs
parents: 20
diff changeset
    80
    TX_ENTRY
hgs
parents: 20
diff changeset
    81
    MpCollectionContainer::setDataModel(dataModel);
hgs
parents: 20
diff changeset
    82
    if ( mCollectionContext == ECollectionContextAlbums ) {
hgs
parents: 20
diff changeset
    83
        if ( mList ) {
hgs
parents: 20
diff changeset
    84
            mList->setModel(dataModel);
hgs
parents: 20
diff changeset
    85
            if ( mCollectionData->count() ) {
hgs
parents: 20
diff changeset
    86
                mList->scrollTo( dataModel->index(mCurrentAlbumIndex, 0) );
hgs
parents: 20
diff changeset
    87
            }
hgs
parents: 20
diff changeset
    88
        }
hgs
parents: 20
diff changeset
    89
    }
hgs
parents: 20
diff changeset
    90
    else if ( mCollectionContext == ECollectionContextAlbumsTBone ) {
hgs
parents: 20
diff changeset
    91
        if ( mTBone ) {
hgs
parents: 20
diff changeset
    92
            mTBone->setModel(dataModel);
hgs
parents: 20
diff changeset
    93
            mTBone->scrollTo( dataModel->index(mCurrentAlbumIndex, 0) );
hgs
parents: 20
diff changeset
    94
            if ( mTBoneListModel == 0 ) {
hgs
parents: 20
diff changeset
    95
                mTBoneListModel = new MpCollectionTBoneListDataModel(mCollectionData);
hgs
parents: 20
diff changeset
    96
                connect( mTBoneListModel, SIGNAL(albumDataChanged()), this, SLOT(albumDataChanged()) );
36
hgs
parents: 35
diff changeset
    97
                connect( mTBoneListModel, SIGNAL(albumDataAvailable()), this, SLOT(albumDataAvailable()) );
35
hgs
parents: 20
diff changeset
    98
            }
hgs
parents: 20
diff changeset
    99
            mList->setModel(mTBoneListModel);
36
hgs
parents: 35
diff changeset
   100
            if ( mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) {
hgs
parents: 35
diff changeset
   101
                if ( mCollectionData->albumSongsCount() > 1 ) {
hgs
parents: 35
diff changeset
   102
                    emit shuffleEnabled(true);
hgs
parents: 35
diff changeset
   103
                }
hgs
parents: 35
diff changeset
   104
                else {
hgs
parents: 35
diff changeset
   105
                    emit shuffleEnabled(false);
hgs
parents: 35
diff changeset
   106
                }
hgs
parents: 35
diff changeset
   107
            }
hgs
parents: 35
diff changeset
   108
            else {
35
hgs
parents: 20
diff changeset
   109
                emit findAlbumSongs(mCurrentAlbumIndex);
36
hgs
parents: 35
diff changeset
   110
                emit shuffleEnabled(false);
35
hgs
parents: 20
diff changeset
   111
            }
hgs
parents: 20
diff changeset
   112
        }
hgs
parents: 20
diff changeset
   113
    }
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
    TX_EXIT
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
}
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
/*!
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
 Slot to be called when an item is selected by the user.
35
hgs
parents: 20
diff changeset
   119
*/
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
void MpCollectionContainerAlbums::itemActivated( const QModelIndex &index )
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
{
35
hgs
parents: 20
diff changeset
   122
    if ( mCollectionContext == ECollectionContextAlbums ) {
hgs
parents: 20
diff changeset
   123
        mCurrentAlbumIndex = index.row();
hgs
parents: 20
diff changeset
   124
        TX_ENTRY_ARGS("mCurrentAlbumIndex=" << mCurrentAlbumIndex);
hgs
parents: 20
diff changeset
   125
        MpCollectionListContainer::itemActivated(index);
hgs
parents: 20
diff changeset
   126
    }
hgs
parents: 20
diff changeset
   127
    else if ( mCollectionContext == ECollectionContextAlbumsTBone ) {
hgs
parents: 20
diff changeset
   128
        int row = index.row();
hgs
parents: 20
diff changeset
   129
        TX_ENTRY_ARGS("index=" << row);
hgs
parents: 20
diff changeset
   130
        if ( mViewMode == MpCommon::FetchView ) {
hgs
parents: 20
diff changeset
   131
            MpCollectionListContainer::itemActivated(index);
hgs
parents: 20
diff changeset
   132
        }
hgs
parents: 20
diff changeset
   133
        else {
hgs
parents: 20
diff changeset
   134
            emit playAlbumSongs(mCurrentAlbumIndex, row);
hgs
parents: 20
diff changeset
   135
        }
hgs
parents: 20
diff changeset
   136
    }
hgs
parents: 20
diff changeset
   137
    TX_EXIT
hgs
parents: 20
diff changeset
   138
}
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
35
hgs
parents: 20
diff changeset
   140
/*!
hgs
parents: 20
diff changeset
   141
 Slot to be called when scrolling ends in media wall and an album is centered.
hgs
parents: 20
diff changeset
   142
 */
43
hgs
parents: 37
diff changeset
   143
void MpCollectionContainerAlbums::albumCentered( const QModelIndex &index )
35
hgs
parents: 20
diff changeset
   144
{
hgs
parents: 20
diff changeset
   145
    TX_ENTRY
hgs
parents: 20
diff changeset
   146
    if ( mCurrentAlbumIndex != index.row() ) {
hgs
parents: 20
diff changeset
   147
        // Prevent reloading if user just moves the center album a little
hgs
parents: 20
diff changeset
   148
        // and the same album re-centers.
hgs
parents: 20
diff changeset
   149
        mCurrentAlbumIndex = index.row();
hgs
parents: 20
diff changeset
   150
        TX_LOG_ARGS("mCurrentAlbumIndex=" << mCurrentAlbumIndex);
36
hgs
parents: 35
diff changeset
   151
        if ( mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) {
hgs
parents: 35
diff changeset
   152
            if ( mCollectionData->albumSongsCount() > 1 ) {
hgs
parents: 35
diff changeset
   153
                emit shuffleEnabled(true);
hgs
parents: 35
diff changeset
   154
            }
hgs
parents: 35
diff changeset
   155
            // Enable context menu
hgs
parents: 35
diff changeset
   156
            mLongPressEnabled = true;
hgs
parents: 35
diff changeset
   157
        }
hgs
parents: 35
diff changeset
   158
        else {
35
hgs
parents: 20
diff changeset
   159
            emit findAlbumSongs(mCurrentAlbumIndex);
hgs
parents: 20
diff changeset
   160
        }
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    }
36
hgs
parents: 35
diff changeset
   162
    else {
hgs
parents: 35
diff changeset
   163
        // Landed on the same album. Just update menu.
hgs
parents: 35
diff changeset
   164
        if ( mCollectionData->albumSongsCount() > 1 ) {
hgs
parents: 35
diff changeset
   165
            emit shuffleEnabled(true);
hgs
parents: 35
diff changeset
   166
        }
hgs
parents: 35
diff changeset
   167
        // Enable context menu
hgs
parents: 35
diff changeset
   168
        mLongPressEnabled = true;
hgs
parents: 35
diff changeset
   169
    }
35
hgs
parents: 20
diff changeset
   170
    TX_EXIT
hgs
parents: 20
diff changeset
   171
}
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
35
hgs
parents: 20
diff changeset
   173
/*!
hgs
parents: 20
diff changeset
   174
 Slot to be called data model has new data.
hgs
parents: 20
diff changeset
   175
 Two cases:
hgs
parents: 20
diff changeset
   176
     1) User deleted an album.
hgs
parents: 20
diff changeset
   177
	 2) User deleted last song in an album.
hgs
parents: 20
diff changeset
   178
 */
hgs
parents: 20
diff changeset
   179
void MpCollectionContainerAlbums::dataReloaded()
hgs
parents: 20
diff changeset
   180
{
hgs
parents: 20
diff changeset
   181
    TX_ENTRY
hgs
parents: 20
diff changeset
   182
    if ( mCollectionContext == ECollectionContextAlbumsTBone ) {
hgs
parents: 20
diff changeset
   183
        if ( mCurrentAlbumIndex > 0 ) {
hgs
parents: 20
diff changeset
   184
            --mCurrentAlbumIndex;
hgs
parents: 20
diff changeset
   185
        }
hgs
parents: 20
diff changeset
   186
        mTBone->scrollTo( mDataModel->index(mCurrentAlbumIndex, 0) );
36
hgs
parents: 35
diff changeset
   187
        if ( mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) {
hgs
parents: 35
diff changeset
   188
            if ( mCollectionData->albumSongsCount() == 1 ) {
hgs
parents: 35
diff changeset
   189
                emit shuffleEnabled(false);
hgs
parents: 35
diff changeset
   190
            }
hgs
parents: 35
diff changeset
   191
        }
hgs
parents: 35
diff changeset
   192
        else {
35
hgs
parents: 20
diff changeset
   193
            emit findAlbumSongs(mCurrentAlbumIndex);
hgs
parents: 20
diff changeset
   194
        }
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
    }
35
hgs
parents: 20
diff changeset
   196
    else {
hgs
parents: 20
diff changeset
   197
        MpCollectionListContainer::dataReloaded();
hgs
parents: 20
diff changeset
   198
    }
hgs
parents: 20
diff changeset
   199
    TX_EXIT
hgs
parents: 20
diff changeset
   200
}
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
35
hgs
parents: 20
diff changeset
   202
/*!
hgs
parents: 20
diff changeset
   203
 Slot to be called data model has new data.
hgs
parents: 20
diff changeset
   204
 User has deleted one of the songs from TBone list.
hgs
parents: 20
diff changeset
   205
 */
hgs
parents: 20
diff changeset
   206
void MpCollectionContainerAlbums::albumDataChanged()
hgs
parents: 20
diff changeset
   207
{
hgs
parents: 20
diff changeset
   208
    TX_ENTRY
hgs
parents: 20
diff changeset
   209
    emit findAlbumSongs(mCurrentAlbumIndex);
36
hgs
parents: 35
diff changeset
   210
    emit shuffleEnabled(false);
hgs
parents: 35
diff changeset
   211
    TX_EXIT
hgs
parents: 35
diff changeset
   212
}
hgs
parents: 35
diff changeset
   213
hgs
parents: 35
diff changeset
   214
/*!
hgs
parents: 35
diff changeset
   215
 Slot to be called TBone starts scrolling.
hgs
parents: 35
diff changeset
   216
 */
hgs
parents: 35
diff changeset
   217
void MpCollectionContainerAlbums::scrollingStarted()
hgs
parents: 35
diff changeset
   218
{
hgs
parents: 35
diff changeset
   219
    TX_ENTRY
hgs
parents: 35
diff changeset
   220
    // Disable shuffle action from the menu
hgs
parents: 35
diff changeset
   221
    emit shuffleEnabled(false);
hgs
parents: 35
diff changeset
   222
    // Disable context menu
hgs
parents: 35
diff changeset
   223
    mLongPressEnabled = false;
hgs
parents: 35
diff changeset
   224
    TX_EXIT
hgs
parents: 35
diff changeset
   225
}
hgs
parents: 35
diff changeset
   226
hgs
parents: 35
diff changeset
   227
/*!
hgs
parents: 35
diff changeset
   228
 Slot to be called album data is available. This is a result of findAlbumSongs signal.
hgs
parents: 35
diff changeset
   229
 */
hgs
parents: 35
diff changeset
   230
void MpCollectionContainerAlbums::albumDataAvailable()
hgs
parents: 35
diff changeset
   231
{
hgs
parents: 35
diff changeset
   232
    TX_ENTRY
hgs
parents: 35
diff changeset
   233
    int count = mCollectionData->albumSongsCount();
hgs
parents: 35
diff changeset
   234
    if ( count > 1 ) {
hgs
parents: 35
diff changeset
   235
        emit shuffleEnabled(true);
hgs
parents: 35
diff changeset
   236
    }
hgs
parents: 35
diff changeset
   237
    // Enable context menu
hgs
parents: 35
diff changeset
   238
    mLongPressEnabled = true;
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
    TX_EXIT
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
}
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
/*!
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
 Sets up the container by organizing widgets according to its layout.
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
 \reimp
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
 */
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
void MpCollectionContainerAlbums::setupContainer()
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
{
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
    TX_ENTRY_ARGS("mCollectionContext=" << mCollectionContext);
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
    if ( mCollectionData->count() ) {
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
        bool ok = false;
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
        QGraphicsWidget *widget;
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
        if ( mCollectionContext == ECollectionContextAlbums ) {
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
            mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "albums", &ok);
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
            if ( !ok ) {
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
                TX_LOG_ARGS("Error: invalid xml file.");
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
                Q_ASSERT_X(ok, "MpCollectionContainerAlbums::setupContainer", "invalid xml file");
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
            }
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
            if ( !mList ) {
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
                widget = mDocumentLoader->findWidget(QString("albumsList"));
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
                mList = qobject_cast<HbListView*>(widget);
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
                mIndexFeedback->setItemView(mList);
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
                initializeList();
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
            }
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
            if ( mInfoBar ) {
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
                delete mInfoBar;
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
                mInfoBar = 0;
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
            }
35
hgs
parents: 20
diff changeset
   269
            if ( mTBone ) {
hgs
parents: 20
diff changeset
   270
                delete mTBone;
hgs
parents: 20
diff changeset
   271
                mTBone = 0;
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
            }
35
hgs
parents: 20
diff changeset
   273
        }
hgs
parents: 20
diff changeset
   274
        else if ( mCollectionContext == ECollectionContextAlbumsTBone ) {
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
            if ( mViewMode == MpCommon::FetchView ) {
35
hgs
parents: 20
diff changeset
   276
                mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "albumTBoneFetcher", &ok);
hgs
parents: 20
diff changeset
   277
                if ( !ok ) {
hgs
parents: 20
diff changeset
   278
                    TX_LOG_ARGS("Error: invalid xml file.");
hgs
parents: 20
diff changeset
   279
                    Q_ASSERT_X(ok, "MpCollectionContainerAlbums::setupContainer", "invalid xml file");
hgs
parents: 20
diff changeset
   280
                }
hgs
parents: 20
diff changeset
   281
                widget = mDocumentLoader->findWidget(QString("albumTBoneDetail"));
hgs
parents: 20
diff changeset
   282
                mInfoBar = qobject_cast<HbGroupBox*>(widget);
hgs
parents: 20
diff changeset
   283
                mInfoBar->setHeading( hbTrId("txt_mus_subtitle_select_a_song") );
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
            }
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
            else {
35
hgs
parents: 20
diff changeset
   286
                mDocumentLoader->load(QString(":/docml/musiccollection.docml"), "albumTBone", &ok);
hgs
parents: 20
diff changeset
   287
                if ( !ok ) {
hgs
parents: 20
diff changeset
   288
                    TX_LOG_ARGS("Error: invalid xml file.");
hgs
parents: 20
diff changeset
   289
                    Q_ASSERT_X(ok, "MpCollectionContainerAlbums::setupContainer", "invalid xml file");
hgs
parents: 20
diff changeset
   290
                }
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
            }
35
hgs
parents: 20
diff changeset
   292
            widget = mDocumentLoader->findWidget(QString("albumWall"));
hgs
parents: 20
diff changeset
   293
            mTBone = qobject_cast<HgMediawall*>(widget);
37
hgs
parents: 36
diff changeset
   294
            HbIcon defaultIcon( "qtg_large_album_art" );
35
hgs
parents: 20
diff changeset
   295
            defaultIcon.setSize(mTBone->itemSize());
hgs
parents: 20
diff changeset
   296
            mTBone->setDefaultImage( defaultIcon.pixmap().toImage() );
hgs
parents: 20
diff changeset
   297
            mTBone->setScrollBarPolicy( HgWidget::ScrollBarAlwaysOff );
hgs
parents: 20
diff changeset
   298
            mTBone->enableReflections(true);
36
hgs
parents: 35
diff changeset
   299
            connect( mTBone, SIGNAL(scrollingStarted()), this, SLOT(scrollingStarted()) );
43
hgs
parents: 37
diff changeset
   300
            connect( mTBone, SIGNAL(animationAboutToEnd(QModelIndex)), this, SLOT(albumCentered(QModelIndex)) );
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
        }
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
    }
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
    else {
35
hgs
parents: 20
diff changeset
   304
        // Must delete widgets when last song is deleted and view is reloaded.
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
        if ( mInfoBar ) {
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
            delete mInfoBar;
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
            mInfoBar = 0;
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
        }
35
hgs
parents: 20
diff changeset
   309
        if ( mTBone ) {
hgs
parents: 20
diff changeset
   310
            delete mTBone;
hgs
parents: 20
diff changeset
   311
            mTBone = 0;
hgs
parents: 20
diff changeset
   312
        }
20
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
        // Call empty list from base class
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
        setupEmptyListContainer();
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
    }
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
    TX_EXIT
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
}
82baf59ce8dd Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318